https://in.crispstats.com serves the tracking script and receives every event. The script calls it for you, so most sites never touch it directly. Use this reference when you send events from your own server, proxy the collector through your domain, check a setup, report AI crawler hits from your edge, or need the exact payload and status codes.
Routes
All routes allow requests from any origin. Request bodies on
POST /e, POST /p/e, POST /api/event and POST /bot are limited to 16 KB (16,384 bytes); a larger body returns 413 with { "error": "payload_too_large" }. Every route is rate limited; see collector limits.
Who the visitor is
The collector derives the anonymous visitor id from the visitor’s address and User-Agent, then discards both. Which address it uses depends on the route:POST /e
The collector endpoint. It behaves in two ways depending on theAuthorization header.
From a browser
The script sends one JSON payload per event withnavigator.sendBeacon, or fetch with keepalive, as text/plain so the browser sends no preflight. The collector parses the body as JSON whatever the content type, answers 202 Accepted with an empty body at once, and does the work afterwards.
Because a browser request always gets
202, use GET /check to confirm a setup, and the realtime view to confirm events arrive. Troubleshooting covers the usual causes when they do not.
From your server
Send the same payload asapplication/json with Authorization: Bearer cs_sk_…. Write the header exactly like that, with Bearer capitalized and a single space: any other form is treated as a browser request and gets a silent 202. Create the key under API keys on the workspace page with the Events scope (Write and Admin also work); it must cover the site in k. A key with only Read gets 403.
Server calls accept three event types: event, revenue and identify. No IP address or User-Agent is used: the event joins a visit only through vid, a visitor id you saved earlier from crispstats.id() or GET /id. u is required but may be empty.
Without a valid
vid (32 lowercase hex characters), the event is counted on its own and is not linked to any visit. A revenue event carries the amount in a (integer minor units) and the currency in c; without c, the site’s currency is used. A negative amount records a refund, which only a secret key may send.
Server-side events walks through the whole flow.
Payload
The payload uses short keys because the script sends it on every pageview. Onlyk, t and u are required.
What is stored from the URLs
Whatever the script sends, the collector stores the page path with only the query parameters the site keeps (set in the site’s settings); everything else on the query string is dropped. UTM values (utm_source, utm_medium, utm_campaign, utm_term, utm_content, and ref, source or via as the source) are read into their own fields, and the names of ad click ids such as gclid decide the paid channel; their values are not stored. Of the referrer, only the host is stored. A URL fragment is kept only as a hash route (#/settings), never as #access_token=….
Which events count toward the plan
Pageviews and custom events (t of pageview or event) count toward the plan’s monthly events. That includes the events the script sends for you: 404, Outbound link and File download are custom events. identify, revenue, ping, vitals and error do not count, and neither do payments from webhooks. Only stored events count: events dropped as bots, excluded pages or duplicates do not.
GET /id
Returns the anonymous id the collector files this browser’s events under right now. Put it on the checkout asmetadata.crispstats_visitor_id (or client_reference_id) so a payment is attributed to the visit. The script calls it for you through crispstats.id().
cs_pk_ followed by letters, digits, _ or -, 8 to 64 characters in all) returns 400 with { "error": "invalid_key" }. A well-formed key that does not exist still returns an id, so the endpoint does not reveal which keys exist.
Call it from the visitor’s browser: the id is derived from the request, so calling it from your server returns an id for your server, not for the visitor. A site behind a proxy calls <prefix>/id, which reaches GET /p/id. Calling https://in.crispstats.com/id directly from the browser also works on a proxied site, and returns the same id when the proxy forwards the visitor’s address. See visitor id at checkout.
GET /check
Checks a setup and says what the collector sees. It reveals nothing about a key beyond whether it is known (public keys are in every page’s source anyway), and never echoes an address. For a direct install, open it in the browser on the page you are checking; for a proxy, request<prefix>/check so the request takes the same path as the script’s.
An IANA timezone, such as
Europe/Lisbon. Fills location.country when the location would come from the timezone.
The response is never cached. Over the rate limit it returns
429 with { "ok": false, "error": "rate_limited" }.
Proxy routes
A site can serve the script and collector from its own domain with one forwarding rule: everything under a path of yours, such as/mw, goes to https://in.crispstats.com/p/. The script tag then points at your path:
The scripts under
/p are served with exactly the same caching and ETag as /d.js. The older POST /api/event and GET /api/id follow the same rules for location headers, signatures and limits as /p/e and /p/id. Proxy through your domain has ready proxies for Next.js, Cloudflare Workers and other hosts.
What the proxy forwards
Forward only these request headers:content-type, user-agent, accept-language, referer, origin and if-none-match, plus x-forwarded-for set to the visitor’s address. Never forward cookie or authorization: the collector needs neither, and GET /p/check reports cookiesForwarded: true when a proxy does. Return only content-type, cache-control, etag and access-control-allow-origin from the collector’s response; the last one lets the dashboard read <prefix>/check from another origin.
Location
Behind a proxy, Cloudflare’s location data describes your server, not the visitor. A proxy that knows the visitor’s location can pass it on; otherwise the country comes from the browser’s timezone.
Vercel’s
x-vercel-ip-country, x-vercel-ip-country-region and x-vercel-ip-city are read too when a proxy passes them on. A country that is not a real two-letter code, and a region or city that is too long or not printable text, is ignored.
Signed proxies
A server-side proxy can prove a request is its own with the headerx-crispstats-proxy-secret, set to the site’s proxy secret (cs_px_ and 32 hex characters, shown with the proxy setup in the dashboard). Keep it on your server, in an environment variable; never put it in the page. A signed request is fully trusted: its forwarded address and location headers are used.
Without the header, forwarding is trusted as long as the site does not require signing. A site can require signed proxies in its settings: then a request on a proxy route without a valid secret is treated as coming from your server’s address, and its forwarded address and location headers are ignored. This stops anyone from posting events with made-up visitor addresses.
POST /bot
Reports a request from an AI crawler that your edge or middleware saw. AI crawlers do not run JavaScript, so the script cannot count them.
The collector answers
202 for any valid body and records the hit only when the User-Agent matches a known AI crawler. A body that fails validation returns 400 with { "error": "invalid_payload" }. Hits are limited per site. See AI crawlers.
GET /live//count
The number of visitors on the site right now, as shown by the live visitor badge. It works only when the site has the public live count turned on.Cache-Control: public, max-age=10). An unknown site, a key that does not match, a blocked site and a site without the public count all return 404 with { "error": "not_found" }.
GET /d.js and GET /d.core.js
The tracking script./d.js includes every optional module, each switched on by its own attribute; /d.core.js leaves the optional modules out and ignores their attributes. /js/script.js and every /p/{name}.js serve the same file as /d.js, and /p/d.core.js the same as /d.core.js. See script builds.
Other routes
POST /hooks/{provider}/{ref}receives payment webhooks. When you connect a provider with a key, CrispStats creates the webhook at the provider with this URL where the key allows it; you never copy it yourself. Razorpay, the App Store and the Shopify App Store are read on a schedule instead, because CrispStats cannot create a webhook with their keys. See revenue attribution.- Any other path returns
404with{ "error": "not_found" }.
Next steps
Server-side events
Send events from webhooks, crons and background jobs.
Proxy through your domain
Serve the script and collector from your own domain.
Collector limits
How many events an address and a site may send.