Google Tag Manager's JavaScript error trigger is used to fire tags when an uncaught JavaScript exception (window.onError
) occurs. This tag may be used to log error messages in an analytics tool. Use a JavaScript error variable to capture the error message and send the value of that variable when a tag fires.
To configure a JavaScript error trigger:
- Click Triggers New.
- Click Trigger Configuration and choose the JavaScript Error trigger type.
When the trigger fires, the following built-in variables are populated:
- Error Message: The text of the JavaScript error message.
- Error URL: The URL for the page where the error occurred.
- Error Line: The line number in the code where the error was detected.
The JavaScript Error trigger will not report errors that occur before Tag Manager loads, and will only report uncaught exceptions.