Overview
Content Manager
Categories
AdSense
Settings
View site
Edit post
1 min read · draft
Live preview
Save post
Title
Slug
/blog/server-side-analytics
Excerpt
Up to a third of your traffic never fires a client-side tag. A first-party collection endpoint that respects privacy and still gives you numbers.
Content (Markdown)
## The gap Client-side tags are blocked, throttled and dropped. If your reporting drives spend decisions, the gap is not a rounding error. ## First-party collection Serve the collector from your own domain, strip identifiers at the edge, and forward aggregated events. ```ts export async function collect(req: Request) { const body = await req.json(); const event = { path: body.path, referrer: new URL(body.referrer || "https://direct").hostname, ts: Date.now(), }; await queue.push(event); return new Response(null, { status: 204 }); } ``` ## Do not rebuild surveillance Hash nothing you do not need. No raw IPs at rest, no cross-site identifiers. Aggregate counts answer almost every question a marketing team actually has. ## Validate against server logs Your access logs are ground truth. If the collector and the log disagree by more than a few percent, fix the collector before trusting a dashboard.