Skip to content

Instantly share code, notes, and snippets.

@akatakritos
Created June 3, 2013 13:36
Show Gist options
  • Save akatakritos/5698168 to your computer and use it in GitHub Desktop.
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.
<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