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 inSegments, Exports and Alerts. This means you can review any sessions in which an error message occured.

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>

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

<script type="text/javascript">
function getQueryString(key)
var value = "";
var url = window.location.href.toLowerCase();
var start = url.indexOf(key.toLowerCase() + "=");
if (start > -1)
var temp = url.substring(start + key.length + 1);
var end = temp.indexOf("&");
if (end < 0) end = temp.indexOf("#");
if (end < 0)
value = temp;
value = temp.substring(0, end);
return value;
var QueryString = getQueryString('s');
if(QueryString !=""){

window.sessioncamConfiguration = new Object();


window.sessioncamConfiguration.customDataObjects = [];

window.sessioncamConfiguration.customDataObjects.push({ key: "source", value: QueryString });



Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.