Created
June 3, 2013 13:36
-
-
Save akatakritos/5698168 to your computer and use it in GitHub Desktop.
trackEvent patch example. Example of patching Google anayltics push function. As an example, overrides the _trackEvent method to pop an alert with the event details. Finally, call the real analytics function so as to not break the tracking.
This file contains 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
<script type="text/javascript"> | |
(function(){ | |
var realPushFunction = window._gaq.push; | |
window._gaq.push = function(params) { | |
if (params[0] == "_trackEvent") { | |
alert("category: " + params[1] + | |
"\naction: " + params[2] + | |
"\nopt_label: " + params[3] + | |
"\nopt_value: " + params[4]); | |
} | |
return realPushFunction.call(window._gaq, params); | |
} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment