Created
March 15, 2012 22:40
-
-
Save codylindley/2047418 to your computer and use it in GitHub Desktop.
Track Clicks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trackIt: function(p,callback,evil){ | |
//mpg window.mpq.track(label,params{ }); | |
//gaq window._gaq.push('_trackEvent',category,action,label,value); | |
var g = false, m = false; | |
var yesCallback = arguments[1] !== undefined && typeof arguments[1] === 'function'; | |
//window._gaq.push('_trackEvent',p.category,p.action,p.label,p.value); | |
window._gaq.push(['_trackEvent',p.category,p.action,p.label,p.value]); | |
window._gaq.push(function(){ g = true; }); | |
window.mpq.track(p.category,p,function(){ m = true; }); | |
//only call... callback if its actually set | |
if(yesCallback && arguments[2] === undefined){ | |
var check = setInterval (function(){ | |
if(g == true && m == true){ | |
clearInterval(check); | |
callback(); | |
} | |
},10); | |
window.setTimeout(callback,1000); | |
}else if(yesCallback && arguments[2] === 'evil'){ | |
var sleep = function(d){var s = new Date().getTime();while (new Date().getTime() < s + d);}; | |
sleep(1000); | |
callback(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment