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
Banner settings for Banner 1
Compliance Type: Differentiated Consent
Banner settings for Banner 2
The Banner 2 config looks similiar
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:
The “Google Consent Mode” tab looks exactly the same for Banner 1 and Banner 2.
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
The user has opted in to marketing:
Next page view of user:
The default is still “denied” but the “update” with granted comes immediately after the default event.
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”.
This works because the “tech” cookie is configured on compliance screen as “default checked”.
Now analytics_storage is granted by default already.
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.