Shoora
9/14/2012 - 12:55 PM

JavaScript error logging with GA

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);
};