I want the window.onerror handler to be called when an error occures inside the "ga(function(tracker)" function. Apparently the ga function has it's own error handler which prevents the window.onerror handler to be invoked.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
window.onerror = function() {console.log('Hello world') };
ga('create', '********', '********');
ga(function(tracker) {
console.log('Start');
/*
Variable y is undefined
window.onerror should be invoked
*/
var x = y;
console.log('End');
});
ga('send', 'pageview');
Just to be clear. My question is NOT how to track errors with google analytics but how to catch errors inside google analytics scripting.