Search documentation

Search titles, headings, and page summaries.

Server-side tracking

Send a custom event from your backend using a Website-scoped server key.

Server-side tracking is useful when a completed action is known only to your backend.

Before you send an event

Create a Custom events server API key for the Website under Website → Settings → Developer. Keep it in a server environment variable and send it as a Bearer token to POST /api/collect/server.

Server events can be joined to browser journeys using the Graytower visitor ID. Include the visitor's _gt_id cookie value as anonymousId. Do not invent a new ID: a generated UUID will not join the original visitor's Money Map journey. Use a stable UUID as eventId when retrying the same action.

JavaScript
const visitorId = request.cookies.get("_gt_id")?.value;

await fetch("https://graytower.app/api/collect/server", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GRAYTOWER_SERVER_EVENT_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "account_created",
    eventId: crypto.randomUUID(),
    anonymousId: visitorId,
    params: { plan: "pro" },
  }),
});

See the Events API for the exact request fields and responses. For Stripe payment matching from your server, use a Stripe attribution key and the payment matching guide.

Check the result

A 204 response means the request was accepted. Check the corresponding custom event in Goals or a Funnel after processing. If the event is absent, verify the Website key purpose, UUID fields, and tracked-event usage.