The Privacy Suite for WordPress

Adding Global site tag (gtag.js) with Granular Consent

Get compliant today in the European Union, United States, Canada, United Kingdom, Australia & South Africa with the only Privacy Suite for WordPress that offers a fully-featured plugin for Worldwide Compliance.

In the near future Complianz will switch to gtag.js, but in the meantime; here is how to add gtag.js, while controlling consent granularly between script tags. For Tag Manager, please follow this link.

This article will consist of three steps.

  1. Configuring the wizard
  2. Adjusting gtag.js for consent – This can also be used for Google Analytics 4
  3. Adding it to your website

1. Configuring the wizard

In the wizard, under – Statistics, you will need to choose between the following answers:

  • Yes, Anonymous – Choose this if you’re in the EU, do not target Germany or Austria, and have configured Analytics for GDPR. This answer will set Google Analytics before consent.
  • Yes, and the is available to us – Choose this answer if the above doesn’t apply. This answer will set Google Analytics when the category “Statistics” has been consented to.

2. Adjusting gtag.js for consent

A gtag.js can be downloaded and appended to with other tags;

The additions are as followed;

For each category we choose which part of the script can be fired, and what to adjust:

This is also possible with async, but deferring these scripts should be done with care, as they are dependent on each other. Testing this cross-browser is advised, because deferred script might fall back to async in some situations, creating false positives.

3. Adding it to your website

This is a personal preference, but Google states adding this between yourtags on your website. This is either done in your header.php or with a plugin like Header Footer Code Manager. You can use above code to start, and append and adjust where necessary.

Recent articles

The Privacy Suite for WordPress
Get compliant today with the only Privacy Suite made for WordPress


Popular articles

LGPD Brazil and WordPress

The “Marco Civil” and the Brazilian General Data Protection Law (LGPD) In Complianz 5.4 we will add full support for the Civil Rights Framework for

Read More

Join our mailing list - 8 Tips & Tricks in your inbox over the next 8 weeks!