I have to send a google tag manager event when a user press a button in a web. On fact, this button is inside an iframe and after that click, this iframe is closed and another one comes up...
I'm setting this event data on the click event from javascript and then I call dataLayer.push to send that info to google analytics.
I can see this request from firebug but it gets cancelled before it arrives to google as soon as the iframe closes...
Is there any way to wait for this call before closing my iframe? Is there any other way to "push" this data?
Thanks in advance.
Set up the data layer variableClick Variables. Under User-Defined Variables, click New. Click Variable Configuration and select Data Layer Variable as the variable type. In the Data Layer Variable Name field, enter the key exactly as it was written in the code (e.g. bookTitle, not book title.)
The syntax for sending an event with dataLayer.push() is as follows: dataLayer.push({'event': 'event_name'});
The return value, assuming you are referring to when you pasted the code into the console, indicates whether a GTM tag fired in response to the push. "true" means that no tags fired, and "false" means that a tag fired.
Create GTM Timer Trigger The field Interval determines how long the timer will wait after trigger to fire a Tag. To achieve a five-second delay on our Facebook Pixel Tag, enter 5000 milliseconds in the Interval field. If no Limit is placed on this trigger, then it will fire a Tag every consecutive interval.
To make this question more useful for current readers: by now you would create an event listener tag in Google Tag Manager and check the "wait for tags that depend on this event" checkbox (event listener tags did not exist in GTM when this was asked).
(And of course the technical background is a bit different that stated in the question - for one thing datalayer.push does not send data to Google Analytics).
Found here http://www.simoahava.com/gtm-tips/hitcallback-eventcallback/ the event 'eventCallback'. I didn't tested it yet but hope it will work, and as I can see gtm.js contains this event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With