Shoora
9/25/2019 - 10:54 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);
};