Prompt
Block GTM tags until consent
Latest observation
Oct 29, 2026
OpenAI APIWeb search: off
To block Google Tag Manager (and any tags fired through it) until consent is granted, you should prevent GTM from loading or running tracking tags before consent.
Best approach
Use a consent manager / CMP and set GTM to only fire after consent via one of these patterns:
1) Load GTM only after consent
Do not include the GTM snippet on page load. Instead:
- wait for user consent
- then inject the GTM script dynamically
This is the strictest method.
2) Use Google Consent Mode
Load GTM, but default all ad/analytics storage to denied until consent:
analytics_storage: deniedad_storage: deniedad_user_data: deniedad_personalization: denied
Then update consent when the user accepts.
Example:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
analytics_storage: 'denied',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
wait_for_update: 500
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');
</script>
When consent is granted:
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted'
});
In GTM itself
If you’re using GTM, configure:
- Consent Overview
- Tag-level Consent Settings
- Trigger tags only when required consent exists
Important notes
- Blocking the GTM container completely means no tags in GTM can run until consent.
- Using Consent Mode allows Google tags to load in a restricted state, which is often preferred for measurement and compliance.
- For stricter privacy requirements, avoid loading GTM until the user opts in.
If you want, I can give you:
- a GTM-only setup
- a WordPress implementation
- a React / Next.js example
- a Cookiebot / OneTrust integration