Configuring Google Consent Mode v2 using Google Tag Manager and the WordPress Easy Cookie Consent plugin

This video provides a comprehensive guide to configuring Google Consent Mode on a WordPress site using Google Tag Manager, alongside the Easy Cookie Consent plugin. We take an existing (demo) site which already has cookie consent and extend it to comply with Google’s Consent Mode version 2 (CMv2).

We have another article on our site which gives you a detailed explanation of what Consent Mode 2 is and what you’re required to do in order to comply with it.

Initial review and setup

The process begins with a review of the current WordPress site setup, which includes a basic 2024 WordPress theme and the Easy Cookie Consent plugin. The plugin was sufficient for managing consent in earlier versions of consent mode, it easily links with Google Tag Manager and already sends two of the four signals needed in the new CMv2.

Google Tag Manager configuration

The first step in the configuration process involves importing a template into Google Tag Manager to manage consent signals. This template, known as “Consent Mode Google Tags,” allows for the setting of default consent states and updating them based on user actions.

Setting default consent

Using the template, a new tag is created in Google Tag Manager to establish default consent states which are set to “denied” to comply with privacy regulations. This tag is triggered via a special “Consent Initialization” trigger, ensuring it runs before any other site scripts.

Managing consent variables

The next step involves creating variables in Google Tag Manager to store consent states, derived from the cookies set by Easy Cookie Consent. Custom JavaScript variables are used to check these cookies and determine if the user has consented to analytics, marketing, or only necessary cookies.

Updating consent based on user actions

With consent variables in place, the focus shifts to updating consent states when users interact with the consent form. This involves setting up tags in Google Tag Manager that utilize the newly created variables to send updated consent signals to Google.

The consent updates are sent on page load and also when the user makes a selection in the cookie popup. A timed trigger is used to delay the update by 300 milliseconds so that the plugin finishes updating the cookie.

Fine tuning Google Tag Manager for Google Analytics

A final adjustment involves modifying the Google Analytics tag to prevent page views from being sent before consent is confirmed. A parameter is added to the initialisation tag to stop a page_view event being sent and a new event tag is used to send the page_view event once consent has been confirmed.

How we can help you

If you’re struggling with this then get in touch – we can help you. Firstly, we can help you determine what your existing consent settings are and whether you’re compliant with the basic implementation of consent mode 2 or not. Secondly, we can help you do whatever work is needed to ensure that you are compliant.

Get in touch with us today to find out more.

Scroll to Top