Server-side events from a backend
When to track from your backend, how to thread anonymous_id, and patterns for batching.
What to fire server-side
Event
Browser
Server
Threading anonymous_id from the browser
Option A — pass it in the request body
import { getAnonymousId } from "@millimetric/track";
await fetch("/api/signup", {
method: "POST",
body: JSON.stringify({
email,
plan,
anonymous_id: getAnonymousId()
})
});Option B — first-party cookie
Option C — derive it server-side and tell the SDK
Long-running server vs serverless
Long-running (Node server, Express, Fastify, Bun, Express on a VPS)
Serverless / edge (Vercel, Cloudflare Workers, Lambda, Deno Deploy)
Webhooks (Stripe, Slack, Resend, etc.)
Batching backfills
Common pitfalls
Last updated
Was this helpful?