Google Consent Mode v2 for WordPress – implementation example

Learn how to use Google Consent Mode v2 with WordPress and with Beautiful Cookie Banner WordPress plugin. This article gives you a brief intro in Google Consent Mode and shows an easy way how to optimize WordPress with Beautiful Cookie Banner plugin.

Why is consent mode v2 important?

You get a much better tracking accuracy as the traffic and conversion you are missing due to user opt-out will be modelled.

From March on Google Tracking products like Google Ads tracking, Google Analytics 4 and Google Floodlights need consent mode to work properly.

What options do you have?

You can set up the Basic implementation or the Advanced version of it.

Basic

You just push the consent information additionally to the dataLayer. That’s it. Official docs: https://developers.google.com/tag-platform/security/concepts/consent-mode?hl=en

If you have already a working set up, you just set up consent mode additionally. Then additional Information, which is required by google, is added to the google tracking requests.

If you start from scratch you first make sure, that the tags fire when there is consent. You can do this with the “blocking feature” of the premium plugin or with Google Tag Manager (recommended) see here for more info. If that is set up, just add the consent mode signals to get the consent mode infos additionally.

Advanced

You push the consent information to the dataLayer, same as Basic. Additionally you fire all Google Tags always. Independent from the user’s consent. You rely here on the Google tags to handle the data in a GDPR friendly way.

This version is quite controversial from a data privacy point of view. This is why I focus in this article on how to implement the basic version.

Consent mode v2 for WordPress implementation example

Disclaimer: This article does not contain any legal advice of any kind. It only describes the technical implementation.

For Google Tags the important parameters are:

  • analytics_storage
  • ad_storage
  • ad_user_data (new in v2)
  • ad_personalization (new in v2)

Configuration WordPress Cookie Banner

All these examples use this Cookie Banner WordPress Plugin

Configuration example 1

Banner settings

Banner: Banner 1

Compliance Type: Differentiated Consent

Example of WordPress cookie banner using google consent mode v2
Cookie Banner Configuration Example - differentiated consent
Consent Mode Settings

Let’s assume you want to allow all your Google tracking tags to collect data on “Marketing” consent and you want to allow personalization.

This would be the configuration of the Beautiful Cookie Banner WordPress Plugin then:

Example of Google Consent mode v2 configuration for WordPress plugin
HINT: the Google Consent Mode Configuration screen looks different based on the chosen compliance type.

That’s it. Your tags still fire how you have configured them. They just have some additional parameters added to the request.

Result

Tool used in screenshots is Tag Assistant Companion.

On first page view, the user has not opted in to marketing, yet

Tag Assistant result consent mode v2 default

The user has opted in to marketing:

Tag Assistant result consent mode v2 update marketing tags

Next page view of user:

The default is still “denied” but the “update” with granted comes immediately after the default event.

Tag Assistant result consent mode v2 default and update on next page view

Variation configuration example 1: default for analytics_storage to be granted.

To have the consent mode category analytics_storage always granted. You can additionally toggle in consent mode configuration “tech”.

consent mode configuration: analytics_storage granted per default

This works because the “tech” cookie is configured on compliance screen as “default checked”.

consent mode configuration: analytics_storage granted per default - compliance settings

Now analytics_storage is granted by default already.

Tag Assistant result consent mode v2 default and update for analytics_storage  as default granted.

For more unofficial background information of consent mode and how to debug and test it, see this German blog post: markus-baersch.de/blog/consent-mode-2-0-faq/ Unfortunately it is in German, but the build in translation feature of the major browser can help with that.

And here is a good article in english: simoahava.com/analytics/consent-mode-v2-google-tags/

Next Step

How to test Google Consent Mode v2 implementation

Disclaimer: This article does not contain any legal advice of any kind. It only describes the technical implementation.