1

I have a React app and want to install Google Tag Manager on certain pages, but I do not want it present after a user logs in. Is it possible to disable / remove the GTM scripts after a certain user action?

I am using react-gtm-module to install Google Tag Manager but open to other options.

1 Answers1

0

Well, this, basically, answers it: How to unload a javascript from an html?

But a better answer would probably be: don't unload GTM. It's not a good practice. It adds a lot more complexity to your overall logic. People don't expect someone to arbitrarily override deployed scripts' namespaces. It's very likely to cause havoc at some point and it's unlikely the one to debug it would be thankful to you for a thoughtful implementation.

Instead, consider using blocking triggers within GTM to just prevent certain tags from firing.

BNazaruk
  • 6,300
  • 3
  • 19
  • 33