tag-manager
tag-manager copied to clipboard
Add a way to wait for tags to finish when adding a custom event
Google Tag Manager allows to wait for all tags triggered by the event to finish running.
This is useful when you want to redirect user, but don't want browser to cancel all pending network requests.
Example code:
dataLayer.push({
event: 'login',
eventCallback: function () {
window.location = uri;
},
eventTimeout: 2000
})
Hi @Demivan . Thank you for taking the time to create this issue. That sounds like an interesting enhancement. Do you have any documentation about that feature in GTM?
I actually don't have any official documentation. There are just few passing mentions of this functionality in the official docs.
Here are some external explanations of this functionality: https://www.simoahava.com/gtm-tips/use-eventtimeout-eventcallback/ https://www.simoahava.com/gtm-tips/hitcallback-eventcallback/
Implementing this would require adding functionality for async tags to indicate that they have finished running. In GTM this is done using data.gtmOnSuccess
and data.gtmOnFailure
methods.
Thank you @Demivan . That gives use some more background information to go on. This issue has been added to our list for product to review and prioritise.