Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yuriygr/af40cabbdac98138ac33541ab4d8f289 to your computer and use it in GitHub Desktop.

Select an option

Save yuriygr/af40cabbdac98138ac33541ab4d8f289 to your computer and use it in GitHub Desktop.
<script>
if (typeof window.onerror == "object") {
window.onerror = function (msg, url, line, col, error) {
if (typeof(msg) === 'object' && msg.srcElement && msg.target) {
if (msg.srcElement == '[object HTMLScriptElement]' && msg.target == '[object HTMLScriptElement]') {
msg = 'Error loading script';
} else {
msg = 'Event Error - target:' + msg.target + ' srcElement:' + msg.srcElement;
}
}
msg = msg.toString();
ga('send', 'exception', {
'exDescription': line + "-" + col + " " + msg,
'exFatal': false
});
};
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment