1

I have added Google Tag Manager to my React Application with the help of this module - react-gtm-module

So i initialized my GTM on base file as the doc says

  const tagManagerArgs = {
    gtmId: process.env.REACT_APP_GTM_KEY,
  };
  TagManager.initialize(tagManagerArgs);

//This code only executes the first time when the site loads, not on every route change

and i see the script tag in my tag

<script src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXXX&gtm_auth=&gtm_preview=&gtm_cookies_win=x"></script>

So as soons as i open my website i see container load in the debug mode of GTM and see the tag GA - UA-XXXXXXX - All Pages fired properly.

Now i have a button in my home page which on clicking takes me to the new route, so in debug mode i see history change but I want to fire GA - UA-XXXXXXX - All Pages Tag in that history change, which doesn't happen. This tag only gets fired when i refresh the website on any of the routes

Ratnabh kumar rai
  • 1,426
  • 4
  • 21
  • 48

0 Answers0