Hi,
This is possible with JavaScript / DHTML....
Here's a handy JS function to read GET parameters and make them available to the rest of your script as normal variables:I want to set a cookie when a user comes to my site based on the url they use to enter my site, e.g. if the come via http://www.mysite.co.uk/?ref=adwords, I want the cookie to be "adwords"
Having called parsequerystring(), you can then set the cookie based on the value of the "ref" parameter:Code:function parsequerystring() { var qs=location.search.substring(1); var s1=qs.split("&"); for(var i=0;i < s1.length;i++) { var s2=s1[i].split("="); window[s2[0]]=unescape(s2[1]); } } parsequerystring();
Code:document.cookie = ref;To start with, I would suggest creating all your links containing a generic tracking ID that basically means "no javascript" - for example, "unknown". You can then change all tracking IDs based on the cookie set using the script above like this:I then want to replace all the tracking-id parts of all the affiliate links
Don't forget to call the above function using the onload event of the HTML body:Code:<script> function SetTrackingID() { document.body.innerHTML.replace(/unknown/gi,document.cookie); } </script>
Code:<body onload='javascript:SetTrackingID();'>
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks