Skip to main content

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

React apps also need React 18 or newer.

Client

Analytics always reads the current visitor off the Core instance — if the user’s identity changes after 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

initAnalytics throws if no valid pk_(sandbox\|live)_* key is available from either the option or core.getPublishableKey(). Set one before calling it.

React

Register Analytics through EmbeddablesProvider’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

The server client doesn’t add browser context (no UTM/device/country) and only accepts 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 the analytics / analyticsInstance option:
In React, the CLI-generated 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.