Skip to content

Create an Experiment

GrowthBook lets you run experiments either as standalone Experiments or as Experiment rules attached to a Feature flag. Both paths converge on the same experiment editor — the steps below cover the most common path: adding an Experiment rule to an existing feature flag.

Step 1 — Open the Features list and choose a feature

Section titled “Step 1 — Open the Features list and choose a feature”
  1. Log in to GrowthBook at http://localhost:3000 (or your Cloud URL).
  2. In the left sidebar, click Features.
  3. Click the feature you want to experiment on — for example, checkout-experiment.
  1. On the Feature detail page, locate the environment where you want to run the test (e.g. production).
  2. Click Add Rule and select Experiment from the rule-type dropdown.
  3. The experiment editor opens inline.
  1. Under Variations, you will see a Control row already present.
  2. Click Add Variation to create one or more treatment variants.
  3. Set the Value for each variation. For a string feature this is the value the SDK returns — e.g. 'control' and 'variant'.
  4. Give each variation a human-readable Name so reports are readable.
  1. In the Traffic section, set the percentage of users included in the experiment (e.g. 50% to expose half your traffic).
  2. Adjust the weights between variations. Equal weights (50 / 50) are the default and recommended starting point.
  3. GrowthBook uses a deterministic hash of the user ID to assign buckets — the same user always sees the same variation.
  1. Scroll to the Metrics section.
  2. Click Add Metric and search for your primary metric (e.g. checkout_completed).
  3. Add any secondary or guardrail metrics you want to monitor.
  4. Mark exactly one metric as the Primary metric — this is the single source of truth for your decision.
  1. Review the Hypothesis field and type a falsifiable statement, e.g. “Showing the new checkout flow will increase checkout_completed by 5%.”
  2. Click Save Rule, then toggle the environment from Draft to Running.
  3. GrowthBook begins collecting impression and conversion data immediately.

After the experiment is live, use getFeatureValue to read the assigned variation. Branch your logic on the returned string:

import { GrowthBook } from '@growthbook/growthbook';

const gb = new GrowthBook({
  apiHost: 'https://cdn.growthbook.io',
  clientKey: 'sdk-YOUR_DEV_KEY',
  trackingCallback: (experiment, result) => {
    // Send impression to your analytics pipeline
    console.log('Experiment:', experiment.key, 'Variation:', result.variationId);
  },
});

await gb.init({ timeout: 2000 });

const variation = gb.getFeatureValue('checkout-experiment', 'control');

if (variation === 'variant') {
  // Show the new checkout flow
  renderNewCheckout();
} else {
  // Default: show the original checkout flow
  renderOriginalCheckout();
}
Where in the GrowthBook UI do you create an experiment?
What does "traffic split" mean in the context of a GrowthBook experiment?
Why should you define a primary metric before starting an experiment?