Skip to main content

Get started with the Statsig SDK

This quickstart will guide you through quickly installing the Statsig SDK in a client app. If you're looking for a more detailed guide, check out the SDK Overview or read about choosing between client or server SDKs.

The easiest way to get up and running is by adding the Statsig JavaScript snippet to your website.

1. Paste the code snippet

In the <head> section of your website, paste the following code snippet:

<script src="https://cdn.jsdelivr.net/npm/@statsig/js-client@3/build/statsig-js-client+session-replay+web-analytics.min.js?apikey=<REPLACE_WITH_YOUR_CLIENT_KEY>"></script>

2. Add client key

Create a client API key in the Statsig console Settings. Copy and paste it to replace <REPLACE_WITH_YOUR_CLIENT_KEY> in the code snippet from the previous step.

3. Basic usage

First, create a gate on the Feature Gates page in console, then check it in-code:

window.Statsig.instance().checkGate("my_feature_gate_name");
note

You'll want to wait for the SDK to initialize before checking a gate to ensure it has fresh values, one way to accomplish this is waiting for the "values_updated" event.

4. Next steps

Congratulations! You've set up the Statsig JavaScript snippet. You can now start:

See the Javascript SDK reference for more info.