Skip to main content
Run an A/B experiment with a single call. Orwel assigns the visitor to a variant (sticky), fires the exposure automatically, and discovers the experiment for you — then you analyze it against any goal, retroactively.

One call

orwel.experiment(key, variants) returns the variant for the current visitor. Declare variants three ways:
// value map → returns the value to render
const cta = orwel.experiment('hero_cta', {
  control: 'Start free',
  green: 'Create account',
});

// array → returns the variant key
const v = orwel.experiment('layout', ['a', 'b']);

// weighted → returns the variant key
const p = orwel.experiment('price', [
  { key: 'monthly', weight: 70 },
  { key: 'annual', weight: 30 },
]);

How it works

The variant is derived deterministically from the visitor id — the same visitor always sees the same variant, with no server round-trip.
The SDK fires optimize_experiment_impression once, with the experiment key and variant.
The experiment appears in the dashboard from those exposures — no pre-registration, exactly like the events catalog.

Analyzing

Pick any tracked event or conversion as the goal — at analysis time, not upfront. Orwel ties each exposed visitor to whether they hit the goal afterward, and shows conversion rate per variant plus the leading one.
Retroactive goals. Because exposures and conversions are both tied to the visitor, you can measure an experiment against a metric you only thought of later — no need to define the goal before shipping.

Recipes

Common experiments — copy, adapt the key, ship.
// Test two button labels and measure signups.
const label = orwel.experiment('hero_cta', {
  control: 'Start free',
  variant: 'Create account',
});

Next steps

Conversions

Define the goals you measure experiments against.

SDK Reference

The full experiment() signature and options.