Analytics
First-party product analytics that are already wired into your app — pageviews, web vitals, people, funnels and retention.
Analytics on Camplax is first-party: the tracker loads from your app's own domain, events post to your own domain, and the data lands in your project. There is no third-party script and nothing sets a cookie — visitor and session ids live in localStorage, and IPs are truncated before they are stored. For most apps that is enough to run without a consent banner, though that call is yours.
It is already on
You do not install anything. The runtime injects a small script tag into your app's HTML and serves the tracker same-origin:
<script src="/camplax/cx.js" data-proxy="same-origin" data-api="/camplax" defer></script>
The browser posts to /camplax/v1/analytics/i on your own domain; the runtime forwards it to the platform with your project's ingest key, which is also in your app's environment as CAMPLAX_ANALYTICS_KEY. The key never appears in your HTML — it lives on the server side of the proxy. Bots and headless browsers are dropped before they ever count as a visit.
What you get without code
$pageviewon every navigation — including SPA route changes, deduplicated so the same URL does not count twice — with path, referrer, UTM tags, browser, device and screen size attached.$web_vitalevents for LCP, CLS, INP, TTFB and load time — the console's Speed tab.- Errors —
window.onerrorand unhandled rejections are captured and sent to the error tracker, not here. - A live stream — the Live tab shows events as they arrive.
Track your own events
The snippet exposes window.cx.analytics:
window.cx.analytics.track("added_to_cart", { sku: "pro-plan", price: 20 });
window.cx.analytics.page("Pricing"); // a named pageview
window.cx.analytics.identify("user_123", { plan: "pro" }); // attach the account
window.cx.analytics.reset(); // on sign-out — new visitor ids
window.cx.analytics.flush(); // force-send the queued batch
identify ties the anonymous visitor to a user id — one person keeps counting as one across sign-in — and emits a $identify event with the traits. Events batch in the browser and flush every two seconds or at ten events, whichever comes first.
The raw endpoint
Anything that can POST can send events — a backend, a script, another app:
curl https://camplax.dev/v1/analytics/i \
-H "x-camplax-analytics-key: $CAMPLAX_ANALYTICS_KEY" \
-H "Content-Type: application/json" \
-d '{
"sentAt": 1736400000000,
"batch": [{
"event": "added_to_cart",
"distinctId": "anon_9f2…",
"userId": "user_123",
"properties": { "sku": "pro-plan" },
"path": "/pricing"
}]
}'
Send the cak_live_… ingest key as x-camplax-analytics-key or Authorization: Bearer. Each event needs event (letters, $, _, ., /, : or -, up to 200 chars) and distinctId; id, timestamp, sessionId, path, environment and userId are optional. A batch holds 1–50 events in a 256 KB body; replays are deduplicated on the client id. Event properties are scrubbed before storage — keys that look like secrets (password, token, authorization, …) are dropped and secret-looking values are redacted.
The endpoint allows 60 posts a minute per IP and 500 per key. A 429 with analytics_capped means the monthly cap is spent — the app stays up, the events just stop counting.
The console
The Analytics page breaks into tabs:
- Overview and Web — visitors, pageviews, top pages and referrers over a day range, for production, preview or both.
- Speed — the web-vitals percentiles per page.
- Live — the raw event stream.
- People — a row per visitor, and a per-person timeline once
identifyhas run. - Funnels — saved 2–5 step funnels with a conversion window (up to 90 days), or an ad-hoc run.
- Retention — cohort retention by week.
- Export — the event table as CSV.
Settings
Under Settings on the same page:
| Setting | Default | What it does |
|---|---|---|
autoPageviews | on | Send $pageview on navigations |
excludePreview | on | Drop events from preview deploys |
autocapture | off | Autocapture interactions |
retentionDays | 30 | How long events are queryable — 7 to 90 days |
paused | off | Accept nothing until re-enabled |
Rotating the ingest key is one click — the new cak_live_… is shown once.
Limits
- 250,000 production events per project per calendar month, plus a separate 10,000 for preview.
- Hot retention defaults to 30 days; the window is 7–90, and a daily purge enforces it.
$probeevents — written bycamplax probewhen it checks your project — are never shown in the console.- Preview traffic stamps its environment server-side; a client cannot claim to be production.
Under the hood: events land in your project's own database; the tracker is a single-file bundle with no dependencies.