-
How to Capture and Monitor a JavaScript Event in GA4 Using GTM
“Hey buddies, I’ve set up an app on my webpage that works with a JS SDK – it can listen for cool events and run callbacks. Here’s how I do it:
function doThis() { // tell GA4 the event happened } $myApp.push(["on", "event:triggered", doThis]);
Also, I’ve got GTM working on my site. Following the latest and greatest instructions, I managed to place the above code on my page. My setup is basically: ‘Trigger’ as on Window loaded, ‘Tag’ as a Custom HTML (containing the previous code).
Further, I even implemented GA4 via GTM by creating a Tag for the GA4 Configuration – threw in my Measurement ID (on Window Loaded as well).
But here’s where I need your help: I can’t figure out how to track the event from the code above in GA4 through GTM. I was hoping to view this event as easily as I can view page visits.
I kinda feel this should be simple, but I just can’t crack it. Anyone got any tips to help a mate out?”
Log in to reply.