Docs

Experiments

Run A/B tests on feature flag variants and measure conversion lift

Experiments are A/B tests built on top of Rybbit. Each experiment splits your visitors across the variants of a multivariate feature flag, then measures how often each variant completes a conversion goal. Rybbit calculates the conversion rate for every variant, the lift relative to your control, and how confident you can be that the difference is real.

An experiment ties together two features you may already use: a multivariate feature flag decides which variant each visitor sees, and a goal defines the conversion you are optimizing for. If you understand those two pieces, you understand experiments.

How Experiments Work

An experiment has three moving parts:

PartWhat it does
AssignmentA multivariate feature flag assigns each visitor to one stable variant (for example control or variant_a) based on its rollout percentages.
ExposureWhen your code reads the flag with rybbit.flag(), Rybbit records an exposure for that variant. A session counts toward the variant it was first exposed to, and the number of exposed sessions is the denominator for its conversion rate.
ConversionThe experiment's primary goal (a page visit or a custom event) counts as a conversion when it happens in the same session, at or after the session's first exposure.

Because assignment is sticky for a given visitor, a person sees the same variant on repeat visits, which keeps your results consistent.

Creating an Experiment

Open your site in the Rybbit dashboard, go to Experiments, and click New experiment. A guided wizard walks you through each step.

Basics

Give the experiment a name and, optionally, a hypothesis and description. The hypothesis is internal context for your team, something like "Changing the CTA copy will increase signups." It does not affect assignment or tracking.

New experiments are created as drafts. The status is a label for your team: it does not control traffic (see Experiment Lifecycle).

Assignment

Choose how visitors are split into variants:

  • Create a new flag — Define a new multivariate flag with its own variants and rollout split. Each variant needs a unique key, and the rollout percentages must add up to 100%.
  • Use an existing flag — Pick a multivariate flag that is not already attached to another experiment.

Each experiment uses its own multivariate flag. The flag's variant keys (such as control and variant_a) are what you branch on in code.

Goal

Pick the conversion you want to compare variants against:

  • Create a new goal — Define a page goal (a URL path such as /signup/complete) or an event goal (a custom event such as signup_completed). The form provides autocomplete suggestions based on paths and events already seen on your site.
  • Use an existing goal — Connect a goal you already track.
  • Skip for now — Create the experiment without a goal and add one later. Conversion results require a goal.

Review and Implement

Review the assignment flag and goal, then create the experiment. Rybbit creates any new flag or goal you configured, connects them, and shows you the implementation code for the flag. A new flag is created enabled, so traffic is split as soon as your code calls rybbit.flag(), even while the experiment is still a draft. Ship the implementation code when you want the test to begin.

Implementing in Code

Read the experiment's flag in your app and branch your UI or behavior on the returned variant. Reading the flag also records the exposure that powers your results, so make sure it runs wherever the tested experience is shown.

window.rybbit.onReady((rybbit) => {
  const variant = rybbit.flag("checkout_cta", "control");

  if (variant === "variant_a") {
    // Render the variant experience.
  } else {
    // Render the control experience.
  }
});
type ExperimentVariant = "control" | "variant_a";

window.rybbit.onReady((rybbit) => {
  const variant = rybbit.flag("checkout_cta", "control") as ExperimentVariant;

  switch (variant) {
    case "variant_a":
      // Render the variant experience.
      break;
    default:
      // Render the control experience.
      break;
  }
});

If your primary goal is an event goal, fire that event when the conversion action happens:

window.rybbit.onReady((rybbit) => {
  rybbit.event("signup_completed");
});

Page goals need no extra code: Rybbit counts sessions that reach the goal's path automatically.

Use a stable variant for the rybbit.flag() fallback (usually "control") so visitors get a sensible experience before flags resolve. If the flag is disabled, rybbit.flag() returns false rather than your fallback, so make sure any value other than a test variant renders the control experience, as in the examples above.

Reading Results

Each experiment shows a results panel comparing every variant. Results respect the global date range and filters applied on the page.

MetricDescription
VariantThe variant key. The variant keyed control is the baseline; if there is none, the flag's first variant is.
SessionsSessions exposed to that variant, alongside the number that converted.
Conversion rateConversions divided by the number of exposed sessions (the Sessions figure) for that variant.
LiftThe percentage change in conversion rate relative to the control. Positive lift is shown in green, negative in red.
ConfidenceHow confident Rybbit is that the variant's difference from the control is real, based on a two-proportion comparison. Shown only once both the variant and the control have at least 30 sessions.

If no exposures were recorded for the flag (your code never calls rybbit.flag() for it), results fall back to sessions that were assigned a variant, using the flag values attached to every event. The panel notes when it is showing assigned rather than exposed visitors.

Rybbit summarizes the state of each experiment at a glance:

  • No conversions yet — No variant has a conversion in the selected range.
  • Gathering data — No variant beats the control with 95% confidence yet. A completed experiment in this state shows No clear winner.
  • Leading — A variant is outperforming the control with at least 95% confidence.
  • Winner — Shown when a winning variant has been recorded on the experiment.

Avoid stopping an experiment the moment a variant looks ahead. Let it run until it reaches 95% confidence with a meaningful number of conversions, otherwise early noise can masquerade as a real difference.

Experiment Lifecycle

Experiments have four statuses, which you set from the experiment list with Start, Pause, and Complete:

StatusMeaning
DraftCreated, not started.
RunningStarted. Rybbit records when the experiment first started.
PausedMarked as paused.
CompletedFinished. Rybbit records the end time, and a completed experiment can't be restarted.

Status is bookkeeping only. It does not start, pause, or stop assignment, exposures, or conversions: the flag keeps serving variants and results keep accruing whatever the status is. To stop splitting traffic, disable the experiment's flag on the Feature Flags page (every visitor then gets false), or remove the rybbit.flag() branch from your code. A flag attached to an experiment can't be deleted until you delete the experiment.

Best Practices

  • Change one thing at a time so you can attribute any lift to a single difference.
  • Make sure your variant rollout percentages add up to 100% unless you intentionally want unassigned traffic.
  • Read the flag wherever the tested experience renders so every exposed visitor is counted.
  • Pick a primary goal that directly reflects the outcome you care about, not a proxy metric.
  • Wait for 95% confidence and a healthy sample size before declaring a winner.
  • After completing an experiment, ship the winning variant and remove the flag branch to keep your code clean.

Related Documentation:

On this page