Overview
Analytics records visitor activity — page views, clicks, purchases, and custom events — tagged with the current project and visitor identity from Core. Once tracked, that data is available for reporting and analysis in Embeddables.What gets tracked
In browsers,
page:viewed events are automatically enriched with available marketing (UTM) parameters, device type, and a country guess.
Implementation
Requires a
publishableKey on your Core config (or passed directly to initAnalytics).
Everything else in Core works without one, but Analytics authenticates every request with it.Install
Client
initAnalytics, the next trackEvent picks that up automatically.
Any field you set explicitly on an event overrides the value Analytics would have detected automatically.
initAnalytics options
React
Register Analytics throughEmbeddablesProvider’s modules prop — the CLI generates the module list in embeddables/_dist/modules — then read the track hooks anywhere underneath. They share one client per Core instance.
isPending reflects an in-flight track call, not initialization. Before Core and the Analytics module are ready, track calls are no-ops — they never throw or queue.
For project and visitor identity in React, use the Core hooks (
useAppUserId,
useEmbeddablesProjectId) — Analytics React bindings don’t duplicate Core getters. React hooks
never track during server rendering; track from server code through the server entry point below.Server
custom_event:triggered and experiment:assigned — everything else is tracked from the browser.
Timestamps are assigned automatically — you never set one yourself. Each event_name only accepts its own matching fields, so TypeScript flags a payment_value on a page:viewed event before it ever ships.
Wiring Analytics into Experiments or Forms
Analytics never depends on Experiments or Forms, and they never depend on it — the connection is optional. In non-React code, pass the client you already created as theanalytics / analyticsInstance option:
modules are ordered analytics → experiments → forms, so Experiments and Forms read the client back off Core automatically — you don’t wire it yourself. See Experiments and Forms for what each one emits.
