Google Consent Mode V2 for Google Analytics by WooCommerce

How to implement Google Consent Mode V2 with ConsentMagic and Google Analytics by WooCommerce


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

Google Analytics by WooCommerce Consent Setup

Google Tag with Google Analytics by WooCommerce

Add the Google Tag on WordPress with the Google Analytics by WooCommerce plugin.

Manage consent with ConsentMagic

Manage consent with the ConsentMagic WordPress plugin.
You just need to turn ON the Google Consent Mode V2 option on the ConsentMagic Settings page.

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'

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

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