How to track browser console errors

You can track the logging of, or get alerts on, errors in the SessionCam console. For example, you may have a piece of Javascript which contains an error that causes a visitor to leave your site.

By setting up a Custom Variable, you can send a string of data to SessionCam that can be used in segments, Exports and Alerts. This means you can review any sessions in which an error message occurred.

While it’s not possible to pull all console messages, the script below should enable you to pull the data you need to debug any possible errors on your site that could impact conversion.

The following shows an example of an error that can be caught by this script:

  • 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>