How to Implement Google Consent Mode v2 with GTM and GA4 for Accurate Tracking
Source: Dev.to

How Consent Mode v2 Works
Consent Mode v2 works by pushing consent state into the GTM dataLayer before any tags fire. The two key parameters are:
analytics_storage— controls GA4 and analytics tagsad_storage— controls Google Ads conversion tags
You push these via gtag or a dataLayer.push before GTM’s container loads:
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('consent', 'default', {
analytics_storage: 'denied',
ad_storage: 'denied',
wait_for_update: 500
});Updating Consent After User Interaction
When the user grants consent through your banner, update the consent state:
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'granted'
});The wait_for_update parameter tells GTM to hold tag firing until the consent update arrives. If your banner takes longer than this window to respond, tags fire before consent is applied — breaking the whole setup.
Configuring Tags in GTM
In Google Tag Manager, configure Consent Settings on each tag—especially GA4 Configuration and Google Ads Conversion tags. Set these tags to require analytics_storage and ad_storage respectively. Without this configuration, the tags ignore the consent state entirely.
Server‑Side Tagging Considerations
For server‑side tagging setups, consent signals need to be passed through the server container as well. SeersAI supports this with direct GTM integration, handling the dataLayer push and update sequence automatically. This removes the risk of implementation errors and keeps you compliant with GDPR and CCPA without manual scripting.
Full implementation walkthrough with attribution context is on the blog.