Skip to main content
Some actions happen where no browser is involved: a subscription renews, a webhook arrives, a background job finishes. To count them, send the event from your server with one POST to https://in.crispstats.com/e, authenticated by a secret API key (cs_sk_…). Pass the visitor id you saved from the browser, and the event joins that visitor’s history. There is nothing to install: any HTTP client works.
Unlike browser events, server-side events get a real status code back, so you can tell when one was rejected. Server-side custom events count toward your plan like any other custom event; identify and revenue do not.

Set it up

1

Create a secret API key

In the dashboard, open the workspace page (Workspace in the account menu, or Team and API keys below a site’s settings tabs), and under API keys create a key with the Events scope. The Write and Admin scopes also allow sending events; a Read key, the default for the REST API, gets 403 key_not_valid_for_site. Choose whether the key works for every site in the workspace or only this site. Owners and admins can create keys.The key is shown once. Store it as a secret on your server, for example in a CRISPSTATS_API_KEY environment variable. Never send it to a browser.
2

Save the visitor id in the browser

Server-side events attach to a visit only through a visitor id. When the user does something your server will follow up on, such as signing up or starting a checkout, read the id in the browser and send it to your backend:
crispstats.id() returns a Promise of the anonymous id the collector files this browser’s events under right now. It resolves to undefined when the script did not start on the page (for example on localhost or in an opted-out browser) or when the request fails. Store the id with the user or order record. Behind a proxy, crispstats.id() works the same way.
3

Send the event from your server

Post the event where the action happens. In TypeScript, this function is all you need. It runs on Node 18 and later, Cloudflare Workers, Vercel Functions, Deno and Bun:
crispstats-server.ts
Call it from your handler:
Other languages send the same request: see send the request over HTTP.
4

Check the dashboard

Open Events. The event appears with the name and properties you sent.

Send the request over HTTP

The request is the same from any language:
The header must start with exactly Bearer cs_sk_. A request without it is treated as a browser event: it gets an empty 202 even when the event is dropped, and a server’s User-Agent (curl, Node, Python and similar clients) gets it filtered out as a bot. If every request returns 202 but no event appears, check the header.

Request body

The body is JSON, at most 16 KB, in the same format the browser script sends.

How the event is attributed

  • With a valid vid. If that visitor has an open session, the event joins it and takes the session’s source, and the session’s user id when you send none. Otherwise the event is stored under that visitor id on its own, with the source Direct.
  • With i and no vid. The event is filed under a visitor id derived from your user id, so repeated events for the same user land together, and it counts toward that user’s identified profile.
  • With neither. The event is counted, under an id of its own, but belongs to no visit.
Server-side events carry no location, browser or OS, and are recorded with the device type desktop: CrispStats does not use your server’s IP address or User-Agent.

Status codes

Next steps

Visitor id at checkout

Pass the visitor id to your payment provider so revenue is attributed.

API keys

Create, scope, revoke and delete secret keys.

Collector reference

Every endpoint the collector serves at in.crispstats.com.
Last modified on November 24, 2026