Statsig
With Statsig as your organization’s experiment provider, you create and run experiments in Statsig, and a canvas rule
in EdgeKit tests a Statsig arm: “they are in experiment · arm”. On each decide request that reaches such a rule,
EdgeKit asks Statsig which arm the device or user is in. Statsig assigns the arm and records the exposure. EdgeKit
stores no assignment and computes no results.
An organization has one experiment provider at a time: EdgeKit’s own experiments or Statsig.
What you give EdgeKit
Section titled “What you give EdgeKit”Two keys from your Statsig project. EdgeKit keeps both with your organization’s other secrets. They are never in the console’s settings, your draft or a deployed document, and no other organization’s sync or sites use them.
- A Console API key. EdgeKit reads your experiments and segments with it, and only when someone selects Sync experiments or Sync segments. It never reaches your sites. Give it a read-only scope and withhold key access: a Console API key with key access can read and rotate your other keys.
- Your server secret key. Decide asks Statsig for arms with it, and the refresh below fetches your project’s config with it. Email experiments also read the config and log exposures with it.
Your client key stays in your own pages. EdgeKit never holds it.
Enter both in Delivery › Configuration › Experiments once Assigns arms is Statsig. The screen shows whether each key is set and never shows a saved key back; a field left blank keeps its key. A new Console API key takes effect at the next sync. Saving a server secret key redeploys your organization, which takes a few minutes, and its config reaches EdgeKit within a minute after that. Until then, stage refuses a switch to Statsig. When you rotate the key, wait for that redeploy before you revoke the old one. A sync with no Console API key refuses and names the missing key.
Configure your browser SDK with EdgeKit’s device id
Section titled “Configure your browser SDK with EdgeKit’s device id”This step is required. EdgeKit sends Statsig the ids below, and Statsig does not map one id onto another. If your own Statsig browser SDK keeps the stable id it generates for itself, Statsig sees EdgeKit’s assignments under one id and your metrics under another. Both consoles look correct, and the results never join.
| Statsig ID type | What EdgeKit sends | What your browser SDK must send |
|---|---|---|
stableID |
The device id, as stableID |
The same device id, as stableID |
userID |
The signed-in user’s EdgeKit user id | The same EdgeKit user id, as userID |
EdgeKit sends both ids when it knows both, and each experiment reads the one its ID type names. A request with neither gets no arm, and Statsig is not asked. EdgeKit sends no other ID type.
The device id is the device cookie EdgeKit Analytics sets on your domain, the same one device.token reads. Its
name is _ek_nuid unless EdgeKit set another for your site. It is HttpOnly, so page scripts cannot read it: your
server reads it from the page request and writes it into the page. Then pass it, and the user id once the user signs
in, when you create the client:
import { StatsigClient } from '@statsig/js-client';
// Written into the page by your server, from the request's device cookie.declare const deviceId: string | undefined;// The signed-in user's EdgeKit user id, if any.declare const userId: string | undefined;
const client = new StatsigClient('client-your-key', { ...(userId ? { userID: userId } : {}), ...(deviceId ? { customIDs: { stableID: deviceId } } : {}),});
await client.initializeAsync();A device’s first request comes before the cookie exists, so it has no device id and gets no arm from EdgeKit. Events your page logs to Statsig before then do not join.
The config reaches your sites in about a minute
Section titled “The config reaches your sites in about a minute”EdgeKit fetches your Statsig project’s config every minute, for your organization alone, and stores a new copy only when Statsig says something changed. A change you make in Statsig, such as a new split or a shipped experiment, usually applies on your sites within about a minute and at most a few, with no EdgeKit deploy. It appears in no deployment entry.
The refresh starts as soon as EdgeKit holds your server secret key, before you switch experiment provider. If Statsig cannot be reached, or the key is revoked, your sites keep evaluating the last config they had.
Each deployment records the checksum of the Statsig config that was live when it was deployed. Undoing a change by deploying an earlier draft again does not undo a change made in Statsig. See Undo a change.
When Statsig gives no arm
Section titled “When Statsig gives no arm”A rule testing a Statsig arm does not hold when Statsig gives no arm: Statsig cannot be reached, it answers with an error, its config is missing, or the experiment serves no arm. The canvas falls through to its otherwise, as with any rule that does not match, and never to its error outcome. A Statsig outage therefore reads as every user in no arm, and nothing on the decision path reports it.
Sync your experiments
Section titled “Sync your experiments”- In Revenue › Decision Engine › Experiments, select Sync experiments.
- EdgeKit reads every experiment in your Statsig project into your draft, with its display name, status, arms and split. A rule can then name its arms.
- Stage and deploy for a rule naming a new experiment to reach your sites. See Stage and deploy a change.
The sync runs only when someone selects it, so the list can be behind Statsig. A synced experiment is read-only in EdgeKit: change it in Statsig. An experiment that is gone from Statsig stays in the list, marked gone, so the rules naming it still deploy. A Statsig experiment with the same name as one of your EdgeKit records stops the whole sync, and the message names both.
Sync your segments
Section titled “Sync your segments”With Statsig as experiment provider, a canvas rule can test your Statsig segments too: “they are in segment loyal”
or “they are not in segment loyal”. On each decide request that reaches such a rule, EdgeKit asks
Statsig whether the device or user is in the segment. A segment check writes no exposure.
- In Revenue › Decision Engine › Segments, select Sync segments.
- EdgeKit reads every segment in your Statsig project into your draft, by its Statsig id. A rule can then name it.
- Include each synced segment in the next deploy, then stage and deploy. A synced segment arrives left out of it.
A synced segment is read-only in EdgeKit: EdgeKit keeps no copy of its rules, so change it in Statsig. One that is gone from Statsig stays in the list, marked gone, so the rules naming it still deploy. A Statsig segment with the same name as one of your EdgeKit records stops the whole sync, and the message names both. Your existing EdgeKit segments keep working beside the synced ones and stay editable, but you cannot create a new EdgeKit segment: create it in Statsig, then sync. A test on a fact Statsig cannot see, such as a content fact, goes on each rule that needs it.
EdgeKit sends Statsig only the device id and the user id, and Statsig evaluates a segment from those two ids. So:
- A segment testing email, country or any other user attribute reads that attribute as empty.
- An ID-list segment cannot be evaluated on your sites. Its list is not in the config EdgeKit holds. The Segments screen marks it Not evaluable at the edge, and a rule naming it matches neither “in” nor “not in”.
- A segment switched off in Statsig answers “not in it” for everybody: “in” matches nobody and “not in” matches everybody. The Segments screen marks it Switched off in the experiment provider.
When Statsig gives no answer for any other reason, a rule naming the segment matches neither “in” nor “not in”, and the canvas falls through to its otherwise, as it does for a Statsig arm.
What the Experiments screen flags
Section titled “What the Experiments screen flags”Revenue › Decision Engine › Experiments shows each synced experiment’s Statsig display name and status, and an Open in statsig link to the same experiment in Statsig’s console. Under the name it flags what changed in Statsig since the rules were written:
- shipped: serves one arm to everybody: the status is
decision_made. A rule naming the shipped arm matches every user, and one naming another arm matches nobody. - serves no arm: the status is
abandonedorsetup. Every rule naming one of its arms matches nobody. - gone from the experiment provider: the experiment is no longer in Statsig.
- a rule names arm “…”, which no longer exists: an arm was renamed or removed in Statsig. The rule is struck through in its canvas, and the next stage refuses it.
Nothing alerts you to these. They show when someone opens the screen.
Switch experiment provider
Section titled “Switch experiment provider”In Delivery › Configuration › Experiments, choose who Assigns arms. The switch is a draft change and takes effect at the next deploy. Stage refuses it, naming each experiment and the feature and canvas reading it, while:
- switching to Statsig, a rule names one of EdgeKit’s own experiments;
- switching to Statsig, your Statsig config has not reached EdgeKit yet;
- switching away from Statsig, a rule names a Statsig arm or a Statsig segment.
A stage that switches and removes the last such rule in the same draft passes. Leaving Statsig means rewriting every rule that names a Statsig arm or segment first.
Forward events to Statsig
Section titled “Forward events to Statsig”EdgeKit can also send every event your sites collect to your Statsig project, for your metrics and experiment
results to read. Forwarded events carry the same stableID and userID as decide, so they join the arms EdgeKit
assigns.
Forwarding needs its own server secret key, which can come from the same project. EdgeKit sets it up for your organization; holding your server secret key for experiments never turns it on. See Forwarding for what each event carries.
Exposures and preview
Section titled “Exposures and preview”Statsig records an exposure each time a rule in the canvas a request entered reads a Statsig arm, including a rule that reads the arm and does not win. Arms in canvases a request never entered are not read and not exposed. EdgeKit’s own experiments count only the winning rule, so the two counts are not comparable.
No Statsig SDK runs when an email renders, so EdgeKit logs an edition’s exposures itself once the edition is sent,
under the same userID. See Email experiments.
The two previews treat Statsig differently:
- The canvas builder’s Preview band does not ask Statsig. It runs in the console, so every Statsig arm reads as no arm, every Statsig segment as no answer, and a rule testing either falls through to its otherwise. It writes no exposure, and it cannot show which arm a canvas picks.
- A decide request carrying a preview token writes real exposures into your Statsig project. It evaluates Statsig exactly as your sites do, so it is the one preview that tests a canvas reading Statsig arms. A Statsig exposure has no field to mark it as a preview, so these exposures count in your results, and neither console can tell them apart from real ones.