ConverTastictmWhere are Your Conversions REALLY Coming From?A Simple Cookie to Aid Conversion TrackingWhen tracking conversions in your web-server log files, the thing you are looking for is how the customer found your website. That is accomplished by finding the customer's first entry in the log, and then looking at the referrer field to see what website they linked from, or what search they did. Often, you can find the customer's arrival by searching on their IP address. However, if they are on a dial-up connection, that becomes difficult. Also, even always-on cable modems and DSL modems will get different IP addresses when they are turned off and then turned back on. So, to make this process a bit easier, we can send a simple cookie to visiting browsers that includes the date and time of their arrival. We can also have that date-time stamp printed in our server logs each time the visitor accesses one of our pages. Later on, when a visitor becomes a customer, we can spot the date-time stamp in their traffic on our order page, or sign-up page, and then search the server-log files for its first occurance. To accomplish this, we will use a JavaScript that will create the cookie. The script will have to reside on every page of our website. The way we will get the cookie's date-time stamp to appear in our server logs is that we will append it as a source string to our company logo image tags. You don't have to use your company logo here, but it is good for an example since many websites have their logo on every page. Instead of including your logo with a simple HTML IMG tag, you will use the script instead. The script will create, or read the existing cookie, and return an IMG tag with the cookie as a source tag to the browser. When the browser uses that IMG tag to fetch the logo, the source tag will be sent to your server and the cookie will appear in your server log. So, instead of seeing hits like this in your server log: GET /logo.gif ...you will see: GET /logo.gif?arrival=2008-03-01-11:33:15-wkqewyvmgl "arrival" is the name of our cookie. The date-time part is obvious, and the "wkqewyvmgl" is a random string of letters to make the cookie very unique. Instead of putting your logo on your web pages like this: <img src=logo.gif height=47 width=66 border=0> You will use the script like this: <script src=script.js type=text/javascript></script> The ScriptThe script will do the following:
var z = "";
var i = 0;
z=readCookie("arrival");
if (z==null) {
z = "";
for (var n=1; n<=10; n++){
i=Math.round(25*Math.random());
//There is no chr() function, so you have to do this:
z=z+unescape("%"+d2h(i+97));
}
z=MakeDateString() + "-" + z;
createCookie("arrival",z,365);
}
document.write("<img src=logo.gif?arrival=" + z + ">");
function createCookie(name, value, days)
{
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var ca = document.cookie.split(';');
var nameEQ = name + "=";
for(var i=0; i < ca.length; i++) {
var c = ca[i];
//delete spaces:
while (c.charAt(0)==' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0){
return c.substring(nameEQ.length, c.length);
}
}
return null;
}
function d2h(d) {return d.toString(16);}
function MakeDateString()
{
var now = new Date();
var y = "";
var m = "";
var d = "";
var h = "";
var n = "";
var s = "";
y=now.getFullYear();
//The month number is zero-relative.
//Adding the '' converts the number into a string.
m=(now.getMonth()+1) + '';
if (m.length == 1) {m="0" + m;}
d=now.getDate() + '';
if (d.length == 1) {d="0" + d;}
h=now.getHours() + '';
if (h.length == 1) {h="0" + h;}
n=now.getMinutes() + '';
if (n.length == 1) {n="0" + n;}
s=now.getSeconds() + '';
if (s.length == 1) {s="0" + s;}
return y + "-" + m + "-" + d + "-" +
h + ":" + n + ":" + s;
}
The script above ran when you loaded this page right here: All you see is the TechSono logo, right? But now you have a cookie named "arrival" stored in the techsono.com partition of your browser's cookie cache. Click here to see your new cookie. In the techsono.com server logs, there is now an entry that has something like this in the request part: GET /convertastic/logo.gif ?arrival=2008-03-02-17:34:57-kyzoekxkha HTTP/1.1 That was your browser requesting the logo above. If you view the page-source for this page, you will not see an IMG tag pulling in the logo, but the script tag as discussed above. You can download the cookie script, and the script used on the second page to show your cookie here. You will probably need to modify things a bit since you will most likely want to store the script and your logo in different directories where all of your pages can access them. You would want to have the cookie script on each of your web pages that are publicly accessible since you have no way of knowing which page a visitor will use to enter your site. When researching a conversion with ConverTastic, you would get the customer's IP address from your shopping-cart system, and do a search on that. If the customer did not have his browser set to "no cookies", ConverTastic will show the cookie date-string in the request column of the Results window. You would then click the Copy Request button, go back to the Search window, and set-up a request-search by pasting in the request and trimming it down to only the date-string part. You can also set the dates to speed up your search to the date shown in the cookie's date-string. ConverTastic should find the customer's arrival very quickly and you will have the referrer. |
||||