Understanding Consent Mode v2
Consent Mode v2 is Google’s response to evolving privacy regulations. It allows tag firing to adapt in real time based on a user’s consent status for analytics and advertising storage. When consent is denied, the tags still send anonymised signals that can later be reconciled once consent is granted, reducing the loss of conversion data.
Core Concepts to Grasp
Consent signals are generated by a consent management platform (CMP) and communicated to Google tags via the gtag consent API. The two primary signals are ad_storage and analytics_storage. Ad storage governs the ability to set advertising cookies, while analytics storage controls analytics cookies.
Consent Mode v2 introduces three additional states: denied, granted and default. The default state means no explicit consent has been captured yet, prompting tags to operate in a privacy‑first mode.
Preparing Your Environment
Before you modify any tag, verify that your site already loads the global site tag (gtag.js) or Google Tag Manager (GTM). You will also need a CMP that can push consent decisions to the data layer or directly to gtag. Most major CMPs provide ready‑made integrations for Google.
Step 1 – Add the consent API snippet
Place the following script as early as possible in the <head> of each page. It creates a default consent state and ensures that any subsequent tag respects the user’s choice.
- Copy the snippet from Google’s official documentation.
- Replace any placeholder values with your own configuration identifier if required.
- Save and publish the change.
Example:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied'
});
</script>
Step 2 – Integrate the CMP
Configure your CMP to call gtag('consent', 'update', …) when a user makes a choice. The call should supply the exact values for ad_storage and analytics_storage – either granted or denied. Most CMPs fire a data layer event that you can capture in GTM, or they expose a JavaScript callback you can invoke directly.
Make sure the update occurs before any conversion tags fire; otherwise the conversion may be attributed to the default denied state.
Step 3 – Enable Consent Mode v2 for Google Ads
In GTM, edit the Google Ads conversion tag settings. Under “Consent Settings”, select “Enable Consent Mode”. Choose the option that matches your CMP’s data layer variable names. If you use the global site tag directly, add the following line after the consent update:
gtag('set', 'ads_data_redaction', true);
This tells Google Ads to redact personally identifiable information when consent is denied.
Step 4 – Configure GA4
For GA4, the consent update is similar. After the CMP signals consent, run:
gtag('consent', 'update', {
'ad_storage': 'granted',
'analytics_storage': 'granted'
});
GA4 automatically respects the consent state and will buffer events for later processing once consent is granted.
Testing the Implementation
Use Google’s Tag Assistant (Legacy) or the newer Tag Assistant (Beta) to verify that tags fire with the correct consent state. Open the debugging console, simulate a user denying consent, and confirm that the ad_storage and analytics_storage values appear as denied. Then grant consent and observe the change.
Additionally, check the GA4 real‑time report for events labeled “consent_granted” to ensure the transition is recorded.
Common Pitfalls and How to Avoid Them
Late consent updates cause conversion loss because the tag fires before the consent state is applied. Place the CMP script as high as possible in the <head> and fire the update immediately after the user interacts with the consent banner.
Mismatched variable names between the CMP and GTM lead to silent failures. Verify that the data layer keys you reference match exactly, including case sensitivity.
Mixed tag managers – using both GTM and the global site tag on the same page can create duplicate calls. Consolidate to a single method to keep the consent flow clean.
Measuring the Impact
After deployment, monitor the following metrics in GA4 and Google Ads:
- Conversion count before and after consent implementation.
- Percentage of events marked as “consent_missing”.
- Revenue attributed to buffered conversions that appear after consent is granted.
These signals will indicate whether the privacy‑first approach is preserving valuable data or if you need to adjust the timing of the consent update.
Advanced Topics
For large enterprises, consider using Google’s server‑side tagging to offload consent processing to a cloud endpoint. This reduces latency for the client side and provides an additional layer of privacy.
If you serve multiple domains, propagate the consent state via first‑party cookies that respect the same‑origin policy. Ensure each domain reads the consent cookie before initializing tags.
Finally, stay up to date with Google’s release notes. Consent Mode v2 is still evolving, and new parameters such as personalized_ads may be introduced to give even finer control.
Leave a Reply