google-tag-managergoogle-tag-manager-server-side

How can we email-notify when google-TagManager (client) for a specific error?


We want to use a GTM template that does some validation and throws an error accordingly.

How can we email-notify when google-TagManager (client) for a specific error?

> GTM Error:  {"version":"1.1","eventName":"gtm.load","eventId":0,"dataLayerKey":"ecommerce.impressions.0.name","variableName":"Variable Name","error":{"value":"14 Day Challenge - Starts March 9th","condition":"notType","conditionValue":"string"}}

enter image description here


Solution

  • You'll need a backend instance for it. You don't send emails by front-end only. There has to be an smtp server. This question goes into more depth: How to send an email from JavaScript

    GTM template or just custom HTML tag would do though something like this would normally be hosted with the front-end. Either way, your JS would conduct the checks you need, then contact the backend endpoint or API to send the email.

    Email itself is a very unconventional way of tracking errors. Since you're already in GTM, it would be way easier to just send a GA event when errors occur using a CJS variable in the error trigger.