Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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