Skip to content

Instantly share code, notes, and snippets.

@usefulthink
Created May 6, 2011 08:07
Show Gist options
  • Save usefulthink/958595 to your computer and use it in GitHub Desktop.
Save usefulthink/958595 to your computer and use it in GitHub Desktop.
Javascript WTF - clicktracking.
// this is an anonymized but otherwise unmodified copy from the
// documentation of a renowned tracking-provider.
var toSleep = true;
function stopTimer(){toSleep=false;}
function clickTracker(LinkName){
var secureID="XXX";
var redirectUrl="http://wehave.teh-trackingz.com/1px.gif";
img=new Image(1,1);
toSleep=true;
img.src="http://wehave.teh-trackingz.com?key="+secureID+"&url="+redirectUrl+"&lnkname="+LinkName;
img.onload=stopTimer;
if(toSleep==true) {maxDelay(500);}
return true;
}
function maxDelay(gap){
var then,now;then=new Date().getTime();
now=then;
while( toSleep==true&&(now-then)<gap){
now=new Date().getTime();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment