Prompt
How do I connect a CMP to Google Tag Manager?
Latest observation
To connect a CMP (Consent Management Platform) to Google Tag Manager (GTM), the usual goal is to make your CMP send consent choices to GTM so tags only fire when allowed.
Here’s the standard setup:
1) Decide which consent framework you’re using
Most CMPs integrate with one of these:
- Google Consent Mode v2 — recommended for Google products
- IAB TCF v2.2 — common for ad/marketing consent in Europe
- A custom consent signal pushed to GTM via
dataLayer
If you use Google Ads, GA4, or Floodlight, Consent Mode v2 is usually the right approach.
2) Load the CMP before GTM
Your CMP script should load early, ideally in the <head> before the GTM container snippet, so it can set default consent before tags fire.
Example order:
- CMP script
- GTM script
3) Set a default consent state
Before a user chooses, GTM should start with denied or restricted consent.
Example using dataLayer:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
ad_storage: 'denied',
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
wait_for_update: 500
});
</script>
Then GTM loads.
4) Update consent when the user makes a choice
When the user accepts or rejects categories in the CMP, push an update to GTM.
Example:
<script>
gtag('consent', 'update', {
ad_storage: 'granted',
analytics_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted'
});
</script>
If the user declines, keep them denied.
5) Map CMP categories to GTM consent types
Typical mapping:
- Necessary → always allowed, no update needed
- Analytics →
analytics_storage - Marketing/Advertising →
ad_storage,ad_user_data,ad_personalization - Functional → depends on your setup
- Preferences → depends on your setup
If your CMP supports a built-in GTM or Google Consent Mode integration, use that rather than building it manually.
6) Configure GTM triggers and tags
Inside GTM:
- Set Google tags to respect consent
- Use consent checks on triggers where needed
- Ensure tags that require consent are blocked until consent is granted
For Google tags, many templates already support consent mode automatically.
7) Test it
Use:
- GTM Preview mode
- Chrome DevTools
- Google Tag Assistant
- Your CMP’s test environment
Check that:
- default consent is denied
- tags don’t fire before consent
- tags fire after consent is granted
- consent updates are passed correctly
If your CMP has a native GTM integration
Many CMPs offer:
- a GTM template
- a consent API
- a direct Google Consent Mode integration
In that case:
- Install the CMP template in GTM or the CMP script on site
- Enable Google Consent Mode in the CMP dashboard
- Map consent categories
- Publish and test
Common pitfalls
- GTM loads before the CMP
- Consent defaults are not set early enough
- CMP categories don’t match GTM consent types
- Tags are hardcoded outside GTM and ignore consent
- Consent is not updated on user action
- Older tag setups still rely on deprecated cookie behavior
If you tell me which CMP you’re using (OneTrust, Cookiebot, Didomi, Complianz, Usercentrics, etc.) and whether you’re using Google Consent Mode v2, I can give you the exact setup steps and code.