What? How? Why? Was that your reaction when you read the title of my blog? Well, as a developer, it is important for us that the code we have written, should not break or should not be blocked by other scripts. Users are very creative these days – if at all tester misses some use cases, users will encounter some of those for sure. So, you need to make sure that your website is working well with every release and every publish of GTM.
And to complement that trigger, it has built-in variables like
- Error Message ( also known as gtm.errorLineNumber dataLayer variable : It will give value which represents the error description in string format
- Error Url ( also known as gtm.errorMessage dataLayer variable ): It will give third party js file URL or any file URL which from which error occurred.
- Error Line ( also known as gtm.errorUrl dataLayer variable ): This is an integer value that shows which line number has caused an error.
Configure a tag as per the below screenshot and your error reporting will work like a charm:
GIF: js error tag configuration
- Set alerts if your error rate reaches to certain level. This will enable you to minimise the risk in case of any important functionality on your website breaks down or gets affected via a third party script.
- Know which third party scripts are causing issues. Fix them. Below screenshot shows which files are causing these errors.