Skip to content

Instantly share code, notes, and snippets.

@vsr
Created September 14, 2012 12:55
Show Gist options
  • Save vsr/3721754 to your computer and use it in GitHub Desktop.
Save vsr/3721754 to your computer and use it in GitHub Desktop.
JavaScript error logging with GA
// Google Analytics event tracking (Report available at Content->Events in GA)
function gatrack(){
var args = Array.prototype.slice.call(arguments),
params = ['_trackEvent'].concat(args);
if(typeof _gaq !== 'undefined') {
window.setTimeout(function(){ _gaq.push(params); }, 0);
}
}
window.onerror = function(msg, url, line){
gatrack('jserror', url+':'+line, msg);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment