Modern websites rarely run without analytics, advertising pixels, or third-party tracking scripts. Developers integrate tools such as Google Analytics 4, Google Ads, and Google Tag Manager to understand user behaviour and measure conversions.
But implementing these tools also introduces a technical responsibility: making sure they respond correctly to visitors' consent preferences.
This is where Google Consent Mode v2 comes in.
Google Consent Mode v2 provides a framework for communicating consent states to supported Google tags. Instead of treating every visitor the same way, supported tags can adjust their behaviour based on the consent signals they receive.
Let's understand how it works, how to implement it, and what developers should test before deploying it to production.
1. What Is Google Consent Mode v2?
Google Consent Mode v2 is a framework that allows websites and apps to communicate user consent choices to supported Google services.
It works alongside a consent banner or Consent Management Platform (CMP).
For example, consider a website that uses:
- Google Analytics 4
- Google Ads conversion tracking
- Google Tag Manager
- Remarketing tags
A visitor may accept analytics cookies but reject advertising cookies.
The website can communicate these choices through consent signals. Supported Google tags then adjust their behaviour according to the received states.
Important: Consent Mode does not collect consent by itself. You still need a consent interface and an implementation that correctly communicates user choices.
2. Understanding the Four Main Consent Parameters
Consent Mode v2 includes four primary consent parameters that developers should understand.
ad_storage
Controls consent related to advertising storage.
It determines whether supported Google tags can read or write advertising-related cookies.
analytics_storage
Controls consent related to analytics storage.
It affects whether supported Google tags can access analytics-related cookies.
ad_user_data
Controls consent for sending user data to Google for online advertising purposes.
This parameter is particularly relevant to certain advertising measurement use cases.
ad_personalization
Controls consent for personalised advertising, including relevant remarketing features.
When this signal is denied, personalised advertising is restricted for supported Google services.
| Parameter | Purpose |
|---|---|
ad_storage |
Advertising cookie storage |
analytics_storage |
Analytics cookie storage |
ad_user_data |
Advertising-related user data |
ad_personalization |
Personalised advertising |
Other consent types are also available, including functionality_storage, personalization_storage, and security_storage.
3. Basic vs Advanced Consent Mode
One of the most important implementation decisions is choosing between Basic and Advanced Consent Mode.
Basic Consent Mode
In Basic Consent Mode, Google tags are blocked until the relevant consent is granted.
Typical flow:
- Visitor opens the website.
- Consent banner appears.
- Google tags remain blocked.
- Visitor grants the required consent.
- Google tags load.
If the visitor does not grant consent, the relevant tags remain blocked through this implementation.
Advanced Consent Mode
In Advanced Consent Mode, Google tags load with configured default consent states.
These states are commonly set to denied until the visitor makes a choice.
When consent is denied, supported Google tags may send limited cookieless signals.
These signals can support Google's measurement modelling features, subject to eligibility and configuration requirements.
| Behaviour | Basic | Advanced |
|---|---|---|
| Google tags before consent | Blocked | Load with default states |
| Denied consent | No tag requests through the blocked implementation | Limited cookieless signals may be sent |
| Modelling support | Less measurement data may be available | Signals may support modelling |
| Configuration | Controlled tag loading | Default states and consent updates |
The right approach depends on the website's legal requirements, tracking setup, and implementation choices.
4. Implementing Consent Mode v2 with gtag.js
Let's look at a simplified implementation.
Step 1: Configure default consent states
Default consent should be established before relevant Google tags execute.
An illustrative configuration:
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied'
});
This example uses denied defaults. The correct configuration must be determined according to the website's applicable requirements and regional consent rules.
Step 2: Update consent after user interaction
When a visitor makes a choice, update the relevant consent parameters.
Example:
gtag('consent', 'update', {
'ad_storage': 'granted',
'analytics_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted'
});
This example represents a visitor granting all four permissions.
In production, each value must reflect the actual preferences selected by the visitor.
Do not automatically grant every category when a visitor has only accepted one specific category.
Step 3: Configure Google Tag Manager
If your website uses Google Tag Manager, review its built-in consent checks and additional consent requirements.
Google tags support consent-related behaviour, but other third-party tags may require separate configuration.
Do not assume that enabling Consent Mode automatically blocks every tracking script on your website.
5. How the Consent Workflow Works
A typical implementation follows this sequence:
Visitor opens website
|
v
Set default consent states
|
v
Display consent banner
|
v
Visitor selects preferences
|
v
Update consent parameters
|
v
Google tags adjust behaviour
|
v
Maintain consent preferences
The sequence matters.
If default consent is configured too late, tags may execute before the intended consent state is established.
Similarly, collecting preferences without updating the relevant signals can result in incorrect tag behaviour.
6. Testing Consent Mode v2
A working consent banner does not necessarily mean your Consent Mode implementation is correct.
Developers should test multiple scenarios.
Test 1: First visit
- Are default consent states configured?
- Do they execute before relevant Google tags?
- Are tags behaving as expected?
Test 2: Accept all
- Are all relevant signals updated?
- Do supported tags respond correctly?
Test 3: Reject all
- Are denied states maintained?
- Are storage restrictions respected?
- Are any unintended scripts still executing?
Test 4: Custom preferences
- Does accepting analytics but rejecting advertising produce the correct signals?
Test 5: Withdrawal
- Can visitors change or withdraw their preferences?
- Are the updated states communicated correctly?
Useful debugging tools include:
- Google Tag Assistant
- Browser Developer Tools
- Google Tag Manager Preview Mode
7. Common Developer Mistakes
Setting defaults after tag execution
This can cause tags to run before the intended consent state is applied.
Updating only two parameters
Older implementations may include only ad_storage and analytics_storage.
Consent Mode v2 also requires consideration of ad_user_data and ad_personalization for relevant use cases.
Assuming Consent Mode blocks every tracker
Consent Mode communicates consent states to supported Google technologies. Other scripts need their own consent controls.
Testing only the Accept button
Reject, custom preference, and withdrawal scenarios are equally important.
Treating Consent Mode as legal compliance
Technical implementation alone does not guarantee compliance with GDPR or other privacy regulations.
8. Where Does a CMP Fit into the Architecture?
A Consent Management Platform helps connect the user-facing consent interface with the technical enforcement layer.
Depending on its capabilities, a CMP can:
- Display consent banners.
- Collect category-level preferences.
- Apply region-specific rules.
- Communicate consent states to Google.
- Block configured non-essential scripts.
- Maintain consent records.
- Support preference changes and withdrawal.
ConsentX is a CMP developed by IntelligenceX. It supports Google Consent Mode v2 and provides features such as a cookie consent banner, Region Rule Engine, prior-script blocking, and consent records.
Developers can explore:
You can also try the free cookie scanner to identify cookies and trackers detected on a public website.
9. Final Thoughts
Google Consent Mode v2 is not simply another tracking configuration. It is an important part of building websites where analytics and advertising technologies respond to user consent choices.
For developers, the key areas are correct default states, accurate consent updates, proper tag configuration, and thorough testing.
A CMP can simplify the consent management process, but the actual implementation still needs to be reviewed and tested.
Have you implemented Google Consent Mode v2 using gtag.js or Google Tag Manager? What challenges did you face?
Share your experience in the comments.
Top comments (0)