Code Library
Production-correct snippets. De-identified. Module-mapped to the Advanced GTM & Server-Side Tracking course.
GA4 base config through GTM (consent-gated)
Configure a GA4 tag in GTM that fires only when analytics_storage is granted. The correct implementation of GA4 with Consent Mode v2.
GA4 Measurement Protocol: server-side event from a Next.js route handler
Send a GA4 event directly from a Next.js route handler using the Measurement Protocol. Sessions stitch correctly when client_id is read from the _ga cookie.
Cross-domain linker configuration
Configure GA4 cross-domain measurement so sessions are not broken when visitors move between domains or subdomains.
GA4 ecommerce purchase dataLayer (generic)
The complete GA4 purchase event dataLayer push. Production-correct schema with all required and recommended parameters.
Shopify purchase dataLayer via Customer Events
Fire the GA4 purchase event from Shopify's Customer Events API (web pixels). Works with the new checkout extensibility without requiring checkout.liquid access.