Tracking browser console errors

At times you may wish to get alerts based on, or simply track the logging of, errors in the browser console itself. For example you may have a block of Javascript that contains an error, this may have impacted the visitor and caused them to leave your site.

Using the power of SessionCam Custom Variables you can send a string of data to SessionCam that can be used in the Filters/Segments, Exports, and Alerts to review any sessions that saw an error message. It's not possible to pull all console messages, however the script below should enable you to pull the data you need to debug any possible errors on your site that could impact conversion.

An example of an error that can be caught by this script would be:

  • Uncaught exceptions
    • throw "some messages"
    • call_something_undefined()
    • cross_origin_iframe.contentWindow.documen, a security exception
  • Compile error
    • <script>{</script>
    • <script>for(;)</script>
    • <script>"oops</script>

The code snippet below can be added to your page and will log JavaScript errors once the page has loaded.