Install Statsig Session Replay
Install Statsig Session Replay by adding the plugin to your JavaScript or React client SDK and configuring sampling, privacy, and capture options.
Statsig supports Session Replay on the Javascript and React SDKs for both desktop and mobile web users. Follow the instructions below to install the SDK and record user sessions.
Option 1 - No code - Add Javascript snippet to your website
<script src="https://cdn.jsdelivr.net/npm/@statsig/js-client@3/build/statsig-js-client+session-replay+web-analytics.min.js?apikey=[YOUR_CLIENT_KEY]"></script>
Get YOUR_CLIENT_KEY from Project Settings > Keys & Environments. Reveal the Client API Key, copy, and paste it over the [YOUR-API-KEY] in the snippet above.
This auto-initializes the SDK and starts recording sessions, no code required.
To use your existing Statsig integration or customize further, refer to option 2 below. To use the script tag with customization, remove your key from the script URL and initialize using the JavaScript code below.
Option 2 - Custom code - Install using a package manager
npm install @statsig/js-client @statsig/session-replay @statsig/web-analytics
Statsig recommends Autocapture for getting started quickly. To skip automatic event logging, remove the runStatsigAutoCapture option from the JavaScript snippet or skip the @statsig/web-analytics package installation.
import { StatsigClient } from "@statsig/js-client";
import { runStatsigSessionReplay } from "@statsig/session-replay";
import { runStatsigAutoCapture } from "@statsig/web-analytics";
const client = new StatsigClient(
sdkKey,
{ userID: "some_user_id" },
{ environment: { tier: "production" } } // optional, pass options here if needed
);
runStatsigSessionReplay(client);
runStatsigAutoCapture(client);
await client.initializeAsync();
To use Conditional Triggers, you must use StatsigTriggeredSessionReplay. Refer to Configure (next page) for more information.
Continue to Configure to learn more about controlling who, what, and when you record sessions.
Was this helpful?