Core Concepts

A/B Experiments

Hypothesis-driven A/B testing with traffic allocation, conversion tracking, exposure recording, and statistical analysis.

Track Conversions

Record when a user completes a goal action (signup, purchase, etc.) for an experiment. This data is used to calculate statistical significance.

typescript
await client.trackConversion({
  experimentId: "exp_xyz",
  variationId: "var_abc",  // from evaluateFlag().variationKey
  metricKey: "signup",
  value: 1.0,              // optional numeric value
  userId: "user_42",
});

Record Exposures

Record when a user is exposed to a variation (i.e., they actually saw the experiment variant). This is critical for accurate statistical analysis.

typescript
await client.recordExposure({
  experimentId: "exp_xyz",
  variationId: "var_abc",
  userIdentifier: "user_42",
});

Auto-Experiment Events

Track general metric events that are automatically associated with running experiments. The backend matches events to experiments based on the metricKey.

typescript
await client.track({
  metricKey: "purchase_completed",
  userIdentifier: "user_42",
  value: 29.99, // optional numeric value (e.g., revenue)
});

Experiment Lifecycle

Experiments go through these states:

DRAFT

Experiment created but not yet active. No traffic is routed.

RUNNING

Actively routing traffic and collecting data.

PAUSED

Temporarily stopped. Existing data is preserved.

COMPLETED

Experiment ended. Results are finalized with statistical analysis.

Backend Endpoints

EndpointMethodDescription
/sdk/experiments/:id/trackPOSTTrack a conversion for an experiment
/sdk/trackPOSTAuto-experiment event tracking
/sdk/exposePOSTRecord experiment exposure