{# Google Tag Manager — head snippet (v0.61.0 Phase 3).
Consent Mode v2 bootstrap runs BEFORE gtm.js loads so GTM receives the
user's current consent state on first call. The `wait_for_update` value
gives client-side JS 500ms to update consent after load (relevant when
the user has decided but the cookie parse runs late).
The gtag() function itself is defined before the GTM container loads.
GTM's own setup snippet then pushes 'gtm.js' and the container ID onto
dataLayer to start tag firing.
Parameters expected in `provider.params`:
- id: GTM container ID ("GTM-XXXXXX")
Context vars expected:
- consent: dict with analytics/advertising/personalization/functional booleans
#}
{% set cm = {
'analytics_storage': 'granted' if consent.analytics else 'denied',
'ad_storage': 'granted' if consent.advertising else 'denied',
'ad_user_data': 'granted' if consent.advertising else 'denied',
'ad_personalization': 'granted' if (consent.advertising and consent.personalization) else 'denied',
'functionality_storage': 'granted',
'personalization_storage': 'granted' if consent.personalization else 'denied',
'security_storage': 'granted'
} %}
{# Google Tag Manager #}
{# End Google Tag Manager #}