-
-
Save Shoora/acad7bdb6c8672641aa82037e56fdac4 to your computer and use it in GitHub Desktop.
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
// definition of trackEvent method on a global object | |
$3N = { | |
trackEvent : function(category, action, label, value){ | |
if (typeof(pageTracker) == "object") pageTracker._trackEvent(category, action, label, value); | |
else if(typeof(_gaq) == "object") _gaq.push(['_trackEvent', category, action, label, value]); | |
} | |
}; | |
// example of using trackEvent in my onerror helper (which you may also want to use) | |
window.onerror = function(msg, url, linenumber){ | |
var handle_error = function(msg, url, linenumber) { | |
$3N.trackEvent( | |
"Error", | |
msg, | |
navigator.userAgent, | |
linenumber | |
); | |
}; | |
if ($3N.dom_ready) | |
handle_error(msg, url, linenumber); | |
else | |
window.addEvent('domready', handle_error.bind(window, [msg, url, linenumber])); | |
}; | |
window.addEvent('domready', function() { $3N.dom_ready = true; }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment