Skip to content

server-side-tracking

Use when implementing server-side tracking, building a unified /api/track endpoint, setting up Conversions API fan-out to Meta/GA4/Pinterest/PostHog, configuring consent management, or implementing PII hashing. Also use when debugging event deduplication, attribution models, or CAPI health.

ModelSource
sonnetpack: cro
Full Reference

A single /api/track endpoint receives every conversion event, enriches it with server-side data, enforces consent, hashes PII, and fans out to every platform in parallel. No ad blockers. No cookie drift. No scattered pixels. One source of truth.

Analytics-tier platforms (GA4 basic events, PostHog) always fire. Marketing-tier platforms (Meta CAPI, Pinterest CAPI, Google Ads) are GPC-gated and consent-checked before every call. The endpoint always returns HTTP 200 — tracking never breaks UX.

ItemValue
Meta CAPI endpointPOST https://graph.facebook.com/{api_version}/{pixel_id}/events
GA4 MP endpointPOST https://www.google-analytics.com/mp/collect
Pinterest CAPI endpointPOST https://api.pinterest.com/v5/ad_accounts/{id}/events
PostHog packageposthog-node
GPC headerSec-GPC: 1 blocks all marketing-tier platforms
Pinterest token expiry60 days (continuous refresh since May 2025)
Meta event dedup window48 hours
Meta EMQ target≥ 6.0
GA4 session cookie formatGS1 (pre-May 2025) or GS2 (May 2025+)
Fan-out methodPromise.allSettled() always — never Promise.all()
I want to…File
Understand the full pipeline architecturereference/architecture.md
Extract cookies and enrich events server-sidereference/cookie-extraction.md
Hash PII before sending to platformsreference/pii-hashing.md
Configure consent tiers and GPC enforcementreference/consent.md
Implement Meta CAPI, GA4, Pinterest, PostHog, and Google Ads fan-outreference/platform-fanout.md
Map events consistently across all platformsreference/event-taxonomy.md
Set up attribution models and identity resolutionreference/attribution.md
Configure cron jobs for batch uploads and health checksreference/cron-infrastructure.md
Verify launch readiness with per-platform checklistreference/launch-checklist.md
Know the non-negotiable safety gatesreference/safety-gates.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.


┏━ 📡 server-side-tracking ━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Unified /api/track endpoint fanning out to Meta, GA4, Pinterest, PostHog ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛