
How to Implement Google Consent Mode v2 with GTM and GA4 for Accurate Tracking
If you are building or managing a marketing analytics stack, Consent Mode v2 is one of the most important configurations you can get right. Getting it wrong means your conversion data is systematically incomplete — and the errors are silent. No error logs. Just missing data. Here is what you need to understand technically. 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 tags — and ad_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 }); When the user grants consent through your banner, you update: gtag('consent', 'update', { analytics_storage: 'granted', ad_storage: 'granted' }); The wait_for_update parameter tells
Continue reading on Dev.to Tutorial
Opens in a new tab


