A/B Experiments
Hypothesis-driven A/B testing with traffic allocation, conversion tracking, exposure recording, and statistical analysis.
Record when a user completes a goal action (signup, purchase, etc.) for an experiment. This data is used to calculate statistical significance.
await client.trackConversion({
experimentId: "exp_xyz",
variationId: "var_abc", // from evaluateFlag().variationKey
metricKey: "signup",
value: 1.0, // optional numeric value
userId: "user_42",
});Record when a user is exposed to a variation (i.e., they actually saw the experiment variant). This is critical for accurate statistical analysis.
await client.recordExposure({
experimentId: "exp_xyz",
variationId: "var_abc",
userIdentifier: "user_42",
});Track general metric events that are automatically associated with running experiments. The backend matches events to experiments based on the metricKey.
await client.track({
metricKey: "purchase_completed",
userIdentifier: "user_42",
value: 29.99, // optional numeric value (e.g., revenue)
});Experiments go through these states:
Experiment created but not yet active. No traffic is routed.
Actively routing traffic and collecting data.
Temporarily stopped. Existing data is preserved.
Experiment ended. Results are finalized with statistical analysis.
Backend Endpoints
| Endpoint | Method | Description |
|---|---|---|
/sdk/experiments/:id/track | POST | Track a conversion for an experiment |
/sdk/track | POST | Auto-experiment event tracking |
/sdk/expose | POST | Record experiment exposure |