Google Tag Manager (GTM) Google Consent Mode V2 on WordPress

How to implement Google Consent Mode V2 with ConsentMagic

or

If you already have a license, learn how to upgrade it.

GTM Consent Setup

Google Tag with Google Tag Manager

Add the Google Tag on WordPress with Google Tag Manager. Use any dedicated WordPress plugin to add your GTM container.

Manage consent with ConsentMagic

Manage consent with the ConsentMagic WordPress plugin. Make sure the "Google Consent Mode V2" option is turned ON on the ConsentMagic' Settings page, and everything is taken care of.

What is Google Consent Mode

Google expects websites using the Google Tag to send four consent-related parameters that will instruct them how to track, store, and use your data.

These is an example of the consent related code where all the parameters are set to “denied”:

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

The website should allow its visitors to express their consent options, and update the code accordingly. This is an example of a code sent when the ad storage option is modified from “denied” to “granted”:

				
					<script type="text/plain"  data-cs-class="cs-blocker-script" data-cs-slug="googleanalytics" data-cs-label="Google Analytics"  data-cs-script-type="132" data-cs-block="true" data-cs-element-position="body">
function consentGrantedAdStorage() {
  gtag('consent', 'update', {
    'ad_storage': 'granted'
  });
  }
</script>
				
			

In this example, when a visitor lands on the site for the first time, the Google Tag is fired but instructs Google that consent is not granted for any category. The visitor agrees to ad storage, and an update command is sent to Google. The interaction with the visitor is done through a consent popup triggered by ConsentMagic that informs about tracking and allows to express consent.

How to check if Google Consent mode works

Testing Google Consent mode is easy with tagassistant.google.com

Open your site, and look for the Consent tab. I will show you all the details you need. Change your consent options and check if the changes are reflected in the tag. 

PRO TIP: test your website in an incognito window.

Google Consent Mode V2

How to enable Google Consent Mode V2