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. The walkthrough below covers install and setup. For every event name, field, and React helper, open the reference.

Implementation

Install

Analytics needs a publishable key (from em init or the admin app). Add it to your project config when you set up Core, or pass it when you set up Analytics. If Analytics has a key, it can supply one for the rest of your app. Install once, then pick your setup:
Follow the example below: wrap your app once, then record events from your components (for example when someone taps a button).
If you used the CLI, the modules import already turns Analytics on. For event names, fields, and the React helpers (useTrackEvent, and related hooks), see the reference.
Need the full list of events and fields (including what you can send from the server)? See Reference — Events. For React track hooks, see Reference — React.

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, adding Analytics with the CLI also lets Experiments and Forms send events for you — no extra connection step. See Experiments and Forms for what each one records.