This article will cover how to implement your JavaScript Error Tracking within Google Tag Manager to push JavaScript errors into your Data Layer. This will allow Insightech to automatically track these errors in the platform.


Step One - Enable Errors in Google Tag Manager

Within Google Tag Manager, go to Variables → Configure (in the Built-in Variables section) and enable Error message, Error URL, Error Line, Debug Mode



Step Two - Setup a Trigger in Google Tag Manager

Go to Triggers → New → Trigger Configuration → JavaScript Error. Leave all the settings as they are and save the trigger.



Step 3 - Setup Your Tag

Setup your JavaScript tag with this code. This will push all of your JavaScript errors from the front-end into your Data Layer to be picked up by Insightech, or any other platform:


Here is an example of how it will look with the trigger included:

<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'js-error',
'error-message': {{Error Message}},
'error-line': {{Error Line}},
'error-url': {{Error URL}}
});
</script>


Step Four - Publish Your Changes

The final step is to publish all your changes, and your JavaScript errors will begin pushing your Data Layer. 


For further help


If you need further help on setting up your javascript error tracking, simply email support@insightech.com or raise a ticket with our team.