DEV Community

Discussion on: Google Tag Manager Hook for React

Collapse
 
elgorditosalsero profile image
Guido Porcaro

Hi katfromtheventury, thanks and sorry for the late reply.

Basically, when u put the script of the GTM into the index.html, it will load immediately and, to push events you'll have to create a custom hook or use always the window.dataLayer.push (or the custom name you've defined).

With this hook, you can load the GTM when u want, maybe not at the bootstrap of the app, maybe layer or maybe by a custom trigger.

You can also configure the tag manager in the same place without doing it editing the script generated by Google.

Hope this help!