I'm trying to setup ecommerce event configuration of Google Analytics App+Web for a website. Refer to the documentation here.
Because there is a lot of custom code for the ecommerce configuration, I cannot use the general GA App+Web webevent template, so instead I'm using a custom HTML-tag in this case.
As a first test, I tried to fire the following simple event:
<script>
gtag('event', 'blabla', {
'test_param1': 'test_value_1'
});
</script>
However, the event is not correctly sent to GA; instead, the following error in the console is returned:
Uncaught ReferenceError: gtag is not defined
To reproduce, see the following page: https://www.hema.nl/mooi-gezond/make-up/make-up-accessoires/toilettassen-1/toilettas-11830901.html
Additional information:
Does anyone know what's going wrong, why the console error appears and why the event is not sent to GA?
The cause of the problem has been found. The problem seemed to be that gtag() does not work if the App+Web base setup is done with the GTM App+Web base template tag. Instead, an event should first be pushed to the GTM datalayer, and then the GTM App+Web event template should be used to send the event to Google Analytics.
Lots of thanks Gino (working at Merkle) for fixing the issue!