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

Any plans to support Gtag Consent mode? #68

Open
jirsbek opened this issue Oct 22, 2021 · 2 comments
Open

Any plans to support Gtag Consent mode? #68

jirsbek opened this issue Oct 22, 2021 · 2 comments

Comments

@jirsbek
Copy link

jirsbek commented Oct 22, 2021

As stated on https://developers.google.com/tag-platform/devguides/consent?utm_source=pocket_mylist, Google Tag supports 2 consent attributes – ad_storage and analytics_storage.

I would be great, if by default GA was loaded with denied values. I believe this way GA still counts pageviews but not stores cookies.

@andrezimpel
Copy link
Owner

So you would need to run

gtag('consent', 'default', {
  'ad_storage': 'denied'
});

after initializing analytics?

@jirsbek
Copy link
Author

jirsbek commented Oct 23, 2021

According to docs consent tag is supposed to be placed like this:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}

  // Default ad_storage to 'denied'.
  gtag('consent', 'default', {
    'ad_storage': 'denied'
  });

  gtag('js', new Date());
  gtag('config', 'G-XXXXXX');
</script>

<!-- Update this section based on your business requirements. -->
<script>
  function consentGranted() {
    gtag('consent', 'update', {
      'ad_storage': 'granted'
    });
  }
</script>

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