Google Consent Mode v2 and cookies (GDPR): what it is and how to implement it properly
If your site uses Google Analytics, Google Ads or remarketing tags and you receive visits from the European Economic Area, you have heard of Consent Mode v2. It is the mechanism by which your site tells Google what the user has consented to, so that the tags behave accordingly. Note: this article is a general technical guide and not legal advice; specific obligations depend on your case and the applicable regulations (GDPR, national cookie rules).
What problem it solves
The GDPR and cookie rules generally require prior consent for non-essential cookies and storage (analytics, advertising). But companies also need to measure. Consent Mode allows you to:
- Respect the user’s decision: if they reject, the tags don’t use storage or identifiers.
- Keep measuring in aggregate with limited signals, relying on modelling, instead of losing all the data.
The consent parameters
Consent Mode v2 works with four signals:
| Parameter | Controls |
|---|---|
analytics_storage | Storage for analytics (e.g., Google Analytics cookies) |
ad_storage | Storage for advertising |
ad_user_data | Sending user data to Google for advertising purposes (new in v2) |
ad_personalization | Personalised advertising / remarketing (new in v2) |
Each can be granted or denied. The two new signals (ad_user_data and ad_personalization) are the ones Google requires for advertising use with EEA users.
The two implementation modes
- Basic: Google tags do not load until the user consents. More conservative; less data.
- Advanced: tags load from the start but, with consent denied, send only cookieless pings; Google can use them for modelling. More data, but you should assess with your legal adviser whether it fits your privacy policy.
Implementation with gtag.js
The order is critical: first you declare the default consent, before loading the tags, and then you update it when the user decides.
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
// 1) Default value: everything denied until the user decides
gtag('consent', 'default', {
ad_storage: 'denied',
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
wait_for_update: 500 // wait for the CMP for up to 500 ms
});
</script>
<!-- 2) AFTER that, load gtag.js / Google Tag Manager -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
When the user accepts (for example, from your banner):
function acceptAll() {
gtag('consent', 'update', {
ad_storage: 'granted',
analytics_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted'
});
// store the decision so you don't ask again
localStorage.setItem('consent', 'all');
}
function acceptAnalyticsOnly() {
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied'
});
}
On later visits, apply the stored update immediately, before the tags fire.
You need a proper banner (CMP)
Consent Mode is the technical part; the cookie banner is what obtains valid consent. Usual requirements for valid consent:
- Informed and specific per purpose.
- Free: rejecting as easy as accepting (a visible “Reject” button at the same level).
- Prior: no non-essential cookies are activated before consent.
- Revocable: the user can change their decision at any time.
For personalised advertising with Google in the EEA, using a certified consent management platform (CMP) is normally required. Check Google’s current requirements.
Common mistakes
- Loading the tags before the
default: consent is evaluated late and data is sent without permission. - Setting everything
grantedby default “so we don’t lose data”. - Banners with “dark patterns”: a hidden or smaller reject button.
- Not storing the decision and asking again on every page (bad UX).
- Not testing: check in developer tools that, with consent denied, no analytics/advertising cookies are set.
How to test that it works
- Open the site in an incognito window, reject and check in DevTools → Application → Cookies that there are no analytics/advertising cookies.
- Accept and check that they appear and that events reach Analytics (real-time report).
- Use Tag Assistant’s debug mode to see the consent state per tag.
Impact on performance
Analytics and advertising scripts are among the biggest consumers of the main thread. Loading them only when there is consent (basic mode) also helps Core Web Vitals and INP.
Conclusion
Consent Mode v2 doesn’t replace GDPR compliance: it is the technical piece that makes your tags respect what the user has decided. Declare the default state before loading anything, use an honest banner and verify with real tests.
If you need to implement analytics, a cookie banner and Consent Mode correctly on your site, write to me.