我需要跟蹤點擊通過我的EDM,我需要看看有多少點擊通過實際轉換(30天內)在一天結束。跟蹤點擊從EDM到轉換
所以我的想法是,對EDM的每一個環節上,我將其指向我的域名(siteA.com),其中i設置一個cookie,然後將其重定向到他們最初所點擊的實際網站( siteB.com)。
用戶然後點擊立即購買並被髮送到購買網站(siteC.com)。
在購買確認頁面上,我調用駐留在siteA.com上的腳本來獲取我設置的cookie(如果有)並記錄事務。
到目前爲止,我設法步驟3,它呼籲居住在siteA.com劇本,但我無法得到我前面設置cookie的值。我知道它叫做腳本,因爲日誌文件被寫入交易細節,但沒有cookie的細節。我是否在siteA.com上使用了錯誤的回調腳本?或者我完全錯過了什麼?
所以這是我使用的確認頁上的代碼:
<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>
上tracking.php文件,我有以下的javascript代碼:
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();
}
最後,這是我對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 .= "\n tranID:".$tranID;
$current .= "\n currencyCode:".$currencyCode;
$current .= "\n orderValue:".$orderValue;
$current .= "\n mc_cid:".$mc_cid;
$current .= "\n mc_eid:".$mc_eid;
$current .= "\n numberofvisits:".$numberofvisits;
// Write the contents back to the file
file_put_contents($file, $current);