Skip to content

tracking-foundation

Use when setting up the analytics and tracking stack for a site — GTM, GA4, PostHog, Clarity, server-side tracking, CAPI fan-out, and attribution. Also use when the user says “set up tracking” or “analytics stack”.

ModelSource
sonnetpack: seo
Full Reference

Everything else depends on this. SEO audits, CRO analysis, performance monitoring — all built on analytics data. If that data is wrong, every downstream decision is wrong.

This orchestrator builds the complete analytics and tracking foundation from scratch or repairs an existing broken one. Six sequential phases, each building on the previous.

PhaseTaskTime
1. AuditCurrent state — what’s Green / Yellow / Red15–30 min
2. GTMTag management, data layer, Consent Mode v230–45 min
3. AnalyticsGA4 + PostHog + Clarity — all three in parallel30–45 min
4. Conversion/api/track endpoint with two-tier consent + CAPI fan-out60–90 min
5. AttributionFirst-party identity, UTMs, click IDs, attribution model30–45 min
6. VerificationPlatform checks, dedup, consent, end-to-end flow30–45 min
Total3–6 hours
I want to…File
Audit current tracking state and set up GTM with Consent Mode v2reference/audit-and-gtm.md
Configure GA4, PostHog, and Microsoft Clarityreference/analytics-layer.md
Build the /api/track endpoint with CAPI fan-out, dedup, and PII hashingreference/conversion-pipeline.md
Implement attribution tracking and verify the complete setupreference/attribution-and-verification.md

Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.


┏━ 🔍 tracking-foundation ━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Build or repair the complete analytics stack — ┃ ┃ GTM, GA4, PostHog, Clarity, and CAPI fan-out ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛