Code Library
Production-correct snippets. De-identified. Module-mapped to the Advanced GTM & Server-Side Tracking course.
Filter by module:AllModule 3 · GA4 Base ConfigModule 5 · Consent Mode v2Module 6 · Server-Side GTMModule 7 · Enhanced ConversionsModule 8 · Meta CAPIModule 9 · Cross-DomainModule 10 · Ecommerce
Filter by topic:Allattributioncaddycmpconsent-mode-v2conversions-apicross-domaincustomer-eventsdatalayerdeduplicationdockerecommerceenhanced-conversionsevent_idga4gdprgoogle-adsgtmmeasurement-protocolmeta-capimeta-pixelnextjsprivacypurchaseself-hostedserver-sidesgtmsha256shopifyvps
Module 5 · Consent Mode v2
Consent Mode v2 default-deny baseline
Inject a default-deny consent baseline before GTM loads. Covers all regions globally plus an explicit EEA/UK region list.
consent-mode-v2gtmprivacygdpr
Module 5 · Consent Mode v2
Consent Mode v2 update on banner consent
Fire gtag consent update when a visitor accepts or rejects cookies. Covers both the granted and denied paths.
consent-mode-v2gtmcmpprivacy