Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended approach for sending Consent mode data #84

Open
michalpulpan opened this issue Feb 24, 2024 · 1 comment
Open

Recommended approach for sending Consent mode data #84

michalpulpan opened this issue Feb 24, 2024 · 1 comment

Comments

@michalpulpan
Copy link

Hello! Thank you for this amazing library. I'd like to ask you whether there's any recommended approach how to send consent events using react-gtm-hook

  gtag('consent', 'update', {
    'ad_storage': 'granted',
    'analytics_storage': 'granted',
    'ad_user_data': 'granted',
    'ad_personalization': 'granted'
  });

thank you in advance ✌️

@NessDan
Copy link

NessDan commented Oct 22, 2024

+1 to this, I was just about to ask the exact same question and saw someone beat me to the punch 🙏

As of right now I'm creating a hook around useGTMDispatch:

const useConsentAwareGTM = () => {
  const analyticsEnabled = useContext(AnalyticsContext)
  const sendDataToGTM = useGTMDispatch()

  return (data: any) => {
    if (analyticsEnabled) {
      sendDataToGTM(data)
    }
  }
}

But I'd prefer to not have to re-write all of our files to support this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants