Question to Expert Web Developers ($50 to the Charity of your choice)

avatar33

e-Hustler
Dec 5, 2009
3,839
52
48
Calgary, AB
Hey guys,

I have an urgent issue that needs to be dealt with quickly, and whoever helps me solve this, I'll give $50 to the charity of their choice...

Here's the deal: I'm an affiliate for a financial product that allows us to place pre-pop forms on our site. The program uses leads360, and this is what the pre-pop form looks like:

<form action="https://secure.leads360.com/Import.aspx?Provider=CompanyName&CampaignId=MyAffID&url=thank-you-page-URL" name="leadform" method="post" id="CompanyName">

So basically we can put our own thank you page under the "url" attribute and this helps us track conversions.

The issue is: I occasionally get conversions that I am not credited for in their affiliate panel. For instance today I see 2 conversions in my Analytics, but in their affiliate panel I got paid for only 1. Now perhaps the other one didn't qualify, but I don't know since I have no access to the data. (their affiliate panel doesn't show us shit, it just says if the lead qualifies or not... it's entirely based on trust I guess)

My Question is: is there a way to automatically capture the lead before sending it to them through leads360? I'd like to record the information of every lead before the form sends it to them? This will help me figure out if these leads that I am not being paid for are legit or not, and it will also help me send them a follow up email on my own to improve my conversion rates and upsell some other related shit perhaps...

Thanks!
 


Why don't you capture the lead then send it to them via their API ?

I don't know if they do have one but it's pretty easy to setup.

Or.... You could use try to send multiple POST request with AJAX, one to your script and another to them.
 
This should work using jquery.

Upon clicking submit the jquery will prevent default action, then post the data to your url, upon successfully posting to your url it will submit the form to the other site.


Code:
$("input:submit").click(function(e) {
    e.preventDefault();
    $.ajax({
        url: "http://myurl.com",
        type: 'post',
        data: "Provider=" + $("#CompanyName").val() + "&CampaignId=" + $("#MyAffID").val(),
        success: function(result) {
            //now submit form to leads360
            $('form').submit();
        }
    });
});
 
Code:
$(document).ready(function(){


	$('#IDOFYOURFORM').submit(function(){


		var form = $(this),
		formData = form.serialize(),     ///Get all the data of your form
		formUrl = form.action(),          /////// Get the url to post to
		formMethod = form.attr('method'),     /////Get the method
			


	
		$.ajax({
			url: formUrl,
			type: formMethod,
			data: formData,


		});


		return false;	
	});



});

Things could be a little fancier by using a success step getting the result via a json string sent by the POST file. If you need the php to post, just ask :).
 
You rock guys, but how/where are your functions saving the data? Ideally I'd like to receive an automatic email with all the form data every time someone hits the Submit button.
 
Code:
<?

if(isset($_POST['name']))
{
	////You basically do this for all the form you are sending.
	name = $_POST['name'];
	address = $_POST['address'];
		
	-------------------------EMAIL PART-------------------------------------------------
	$to      = 'your email';
	$subject = 'the subject';
	$message = 'hello new customer named {$name} living at {$address}';
	$headers = 'From: ' . "\r\n" .
    	'Reply-To: [email]webmaster@example.com[/email]' . "\r\n" .
   	 'X-Mailer: PHP/' . phpversion();

	mail($to, $subject, $message, $headers);	
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

	//////////////////////Curl PART to post to lead 360//////////////////////
	
	$url = lead flash url;
	$data = array (
		'name' => $name,
		'address' => $address,
	);
		
	$ch = curl_init($url);
	curl_setopt($ch,CURLOPT_POST, true);
	curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER, true)
	$returntransfer = curl_exec($ch);


}

Create a file with the name you setup in the form action ( <form action="post.php''>) so post.php and save it in the same folder as your index page, or wherever you want to.
Use the right path.

I didn't test it, but send me the form id or names you are using and i will setup it correctly.
 
Code:
<?

if(isset($_POST['name']))
{
	////You basically do this for all the form you are sending.
	$name = $_POST['name'];
	$address = $_POST['address'];
		
	-------------------------EMAIL PART-------------------------------------------------
	$to      = 'your email';
	$subject = 'the subject';
	$message = 'hello new customer named {$name} living at {$address}';
	$headers = 'From: ' . "\r\n" .
    	'Reply-To: [email]webmaster@example.com[/email]' . "\r\n" .
   	 'X-Mailer: PHP/' . phpversion();

	mail($to, $subject, $message, $headers);	
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

	//////////////////////Curl PART to post to lead 360//////////////////////
	
	$url = lead flash url;
	$data = array (
		'name' => $name,
		'address' => $address,
	);
		
	$ch = curl_init($url);
	curl_setopt($ch,CURLOPT_POST, true);
	curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER, true)
	$returntransfer = curl_exec($ch);


}

Create a file with the name you setup in the form action ( <form action="post.php''>) so post.php and save it in the same folder as your index page, or wherever you want to.
Use the right path.

I didn't test it, but send me the form id or names you are using and i will setup it correctly.

Edited, a few $ were missing
 
You rock guys, but how/where are your functions saving the data? Ideally I'd like to receive an automatic email with all the form data every time someone hits the Submit button.

There are lots of ways. Simplest would probably be to have the script that you post the info to send out an email with the data passed from the form.

But if you grow to having hundreds or thousands of leads it could be a pain in the ass to keep track of.

Going a little further by inserting data into mysql with timestamps/ip addresses would let you sort by date, ip address, company name, campaign id, etc over time with simple queries.

You could do it in the same php file you post the data to, it could still send you an email as well. Then you could simply say on "x" date range you record "x" submits from "x/y/z" (company/ip/affId/etc.) while leads360 only recorded "x" - "discrepancy".

Just a thought. Something you can think of adding.
 
For this I would have the form post to itself, capture the fields, call their url with cURL within a try / catch and maybe you'll get lucky and they respond with a true or false. Then do as you please with captured fields, save to db, send email. etc.
 
For this I would have the form post to itself, capture the fields, call their url with cURL

Though this would work, it's a bad idea, here is why: Networks like to keep track of IP addresses. If you send the request through cURL, then you are the one sending the request (not your user), and your IP will show up for all conversions. This will make all your leads look fraudulent.

I would suggest changing the submit button so that instead of just submitting the form (as the browser normally would), it would call a javascript function. In your javascript function, do an ajax call to a script on your server that logs/emails the info you want, then call whateverForm.submit().

The only concern with this method is that anyone can spam your logging page to troll you.



I would also like to suggest logging a bunch of HTTP header information on the "thank you" page, the referrer being the most important. If the user read your source code and just copied the "thank you" page url, then opened it in the browser the browser, the referrer would not be set, letting you know that no actual conversion took place.
 
Though this would work, it's a bad idea, here is why: Networks like to keep track of IP addresses. If you send the request through cURL, then you are the one sending the request (not your user), and your IP will show up for all conversions. This will make all your leads look fraudulent.

I would suggest changing the submit button so that instead of just submitting the form (as the browser normally would), it would call a javascript function. In your javascript function, do an ajax call to a script on your server that logs/emails the info you want, then call whateverForm.submit().

The only concern with this method is that anyone can spam your logging page to troll you.



I would also like to suggest logging a bunch of HTTP header information on the "thank you" page, the referrer being the most important. If the user read your source code and just copied the "thank you" page url, then opened it in the browser the browser, the referrer would not be set, letting you know that no actual conversion took place.

Nowadays, networks give you the ability to append an ip value to the POST url they provide that will make it more legit.

So what could be done is :

- POST the form data to your own script/api or whatever.
- Check if the values are ok.
- Save to your db.
- Then send the info to the network through CURL. They will see your server's ip as the sender, but by appending the IP to the fields you are sending.

That's what i do and it's fine.

Always save the info first in your database, do not rely on the Network response to see if a lead is correct or not. You don't know when they will shave you :)