I need to track click-thru on my edm, and i need to see how many of these click-thru actually convert (within 30 days) at the end of the day.
So my idea is, on every link on the edm, i point them to my domain (siteA.com), where i set a cookie, then redirect them to the actual site where they initially clicked on (siteB.com).
The user then clicks on buy now and gets sent to the purchasing site (siteC.com).
On the purchase confirmation page, i call a script that resides on siteA.com, to grab the cookie that i set (if any) and logs the transaction.
So far, i managed to get to step 3, where it calls the script residing on siteA.com, but i am unable to get the value of the cookie that i set earlier. I know that it called the script, because the log file gets written to with the transaction details, but no cookie details. Am i using the wrong callback to the script on siteA.com? Or am i missing something totally?
So this is the code i'm using on the confirmation page:
<script type="text/javascript">
var adJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + adJsHost + "siteA.com/tracker/tracking.php' type='text/javascript'%3E%3C/script%3E"));
logTransaction (orderValue , orderRef, merchantID, uid , htname, pixel, payoutCodes, offlineCode,checkOutDate,currencyCode);
</script>
on the tracking.php file, i have the following javascript code:
function logTransaction (orderValue , orderRef, merchantID, uid , htname, pixel, payoutCodes, offlineCode,checkOutDate,currencyCode)
{
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","http://siteA.com/tracker/confirmation.php?tranID="+uid+"&orderValue="+orderValue+"¤cyCode="+currencyCode,true);
xmlhttp.send();
}
and finally, this is what i have on the confirmation.php
if (isset($_COOKIE["myedm"])) {
$cookie_array = explode(",", $_COOKIE["myedm"]);
$mc_cid = $cookie_array[0];
$mc_eid = $cookie_array[1];
$numberofvisits = $cookie_array[2];
}
$tranID = $_GET['tranID'];
$orderValue = $_GET['orderValue'];
$currencyCode = $_GET['currencyCode'];
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "
tranID:".$tranID;
$current .= "
currencyCode:".$currencyCode;
$current .= "
orderValue:".$orderValue;
$current .= "
mc_cid:".$mc_cid;
$current .= "
mc_eid:".$mc_eid;
$current .= "
numberofvisits:".$numberofvisits;
// Write the contents back to the file
file_put_contents($file, $current);
Update:
I fixed the problem.. kind of..
changed the javascript calling the file to using a img pix, i.e.
<img src="http://siteA.com/tracker/confirmation.php?tranID=123&orderValue=150¤cyCode=USD">
it works! but only in firefox n chrome. In IE, doesn't seem to want to set the cookie even..