elgorditosalsero / react-gtm-hook

Easily manage the Google Tag Manager via Hook
https://elgorditosalsero-react-gtm-hook.netlify.app/
MIT License
220 stars 28 forks source link

Sever connection when Consent gets disabled #53

Closed Pololinger closed 1 year ago

Pololinger commented 2 years ago

Hi, I'm having the issue that once a user changes the consent from accept to deny to connection to GTM still persists. I have tried overwriting the gtmParms on consent change without success (arbitrary strings or undefined). Collect still pops up in the network tab.

Also I tried to tie useGTMDispatch to the condition of consent being true. Which works but once a consent change happens such as false, true, false, I still get data getting sent to GTM.

It seems no matter what what I do, once the react gtm hook connects to GTM ,its connection can not be disabled again. Has anyone ever run into this problem or knows a way out?

elgorditosalsero commented 1 year ago

Hey @Pololinger, is this still happening?

Sorry for the late answer.

Pololinger commented 1 year ago

No worries. As a workaround we now just reload the page, if the consent gets changed from accept to deny.