//prepare the cookie HttpCookie trackingCookie = new HttpCookie(cookie_name, cookie_value); trackingCookie.Expires = DateTime.Now.AddMonths(1); //this line is a 'compact privacy policy' for IE HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""); //drop tracking cookie Response.Cookies.Add(trackingCookie); //Write image string loc = Server.MapPath("/img/track.gif"); Response.WriteFile(loc); Response.ContentType = "image/gif";
The js code to initiate it, placed in the host website:
document.writeln("");
where the javascript value trackingData is populated by clientside code included (before the above code) like so:
This is some simple javascript that grabs the utm_source, utm_campaign (etc..) values from the URL and puts them into the value of trackingData.
Using this technique we can use specific cookie names and values to provide persistence between visitor sessions and to record and analyze their origins.
No comments:
Post a Comment
Comments are moderated, so you'll have to wait a little bit before they appear!