alinemorelli / react-gtm

React Google Tag Manager
MIT License
658 stars 140 forks source link

How to turn off after initialized? #61

Open LucasAndrad opened 4 years ago

LucasAndrad commented 4 years ago

I have this flow in my app:

  1. When my web app loads I run: TagManager.initialize({ myConfig });
  2. But if my user clicks on Decline Cookies I need to turn it off

Is there any function like: TagManager.turnOff that will remove all cookies associated with Google Tag Manager?

bsteps commented 4 years ago

Same here any solution.

dcorb commented 4 years ago

@LucasAndrad I think ONLY if the user consents with your cookies usage, you should initialize TagManager?

LucasAndrad commented 4 years ago

No @dcorb, that's not the flow the company wants. That first track of TagManager is anonymous, so no need any consent for that (at least following the company country laws)

maxrojasdev commented 4 years ago

How about add a persistent condition-trigger like: if (userAcceptCookies) {TagManager.initialize({ myConfig })}

zuzuleinen commented 4 years ago

Anyone found a solution?

framerate commented 4 years ago

I'm no expert but

That first track of TagManager is anonymous,

So that's fine

Then later, push the userId and other private data into the dataLayer only if they consented. If anonymous data is good prior to consent it should be good after.

Otherwise, convince the company to start it post consent for consistency?

cdelacombaz commented 2 years ago

Having the same issue.

The user could accept all cookies and later on update his preferences to deny tracking for example. That could be a use case to turn off the tag manager. A TagManager.turnOff() method would be handy.

Another option would be to use the API for consent settings via Google Tag manager. https://developers.google.com/tag-manager/templates/consent-apis

However, I didn't manage to make it work with this library.

HuyAms commented 1 week ago

Is there any update here?

I need to turn off the GTM after the user logs in. A util function to disable the GTM would be quite handy