How to A/B test prices with GrowthBook

A GrowthBook pricing test, step by step: one JSON value per price, server-side hashing, sticky bucketing, warehouse revenue metrics and when bandits fit.

Short answer

GrowthBook can run a price test: make the price a JSON feature with one value per variation, evaluate it on your server hashed on a stable visitor ID, log exposures to your warehouse, and define revenue per user as a fact-table metric. Sticky bucketing and bandits need the Pro plan, and the revenue pipeline is yours to build.

  • Model the price as a JSON feature holding the amount and currency, and evaluate it with GrowthBookClient on your server.
  • GrowthBook hashes the assignment attribute with the experiment seed, so a visitor keeps the same price only while the variation weights stay unchanged.
  • Sticky bucketing keeps visitors on their first variation after experiment changes and is a Pro and Enterprise feature.
  • Revenue per user is a mean metric with SUM over a fact table that you build from your Stripe webhook data.
  • GrowthBook bandits use Thompson sampling, keep at least 1% per variation and need 100 users per variation before they reweight.

GrowthBook can run a price test, and it leaves the analysis in your hands: your own warehouse, your own metric SQL, Bayesian or frequentist statistics, and bandits on the Pro plan. That control comes with plumbing. GrowthBook decides which variation a visitor gets; everything that touches money is yours to build. This guide wires both halves together with Stripe, then shows where a pricing test strains GrowthBook's model.

Can GrowthBook run a pricing test?

Yes. A GrowthBook feature can hold a boolean, number, string or JSON value (feature basics), and an experiment rule on that feature serves a different value to each variation. Your server evaluates the feature with the SDK, renders the price and charges the same amount in Stripe. GrowthBook then analyzes the experiment from your warehouse: exposures your tracking callback logged, joined to purchases from your own tables.

As of November 2026, the open-source version is free to self-host, and the Starter cloud plan is free for up to 3 users (GrowthBook pricing). Sticky bucketing and multi-armed bandits require Pro at $40 per seat per month, or Enterprise (plan comparison). Both matter for prices, as you'll see below.

How do you model a price as a GrowthBook feature?

Create a JSON feature, for example pro-price, whose default value is your current price, {"amount": 2900, "currency": "usd"}. Then add an experiment rule with one variation per price:

VariationWeightValue
0 (control)50%{"amount": 2900, "currency": "usd"}
150%{"amount": 3900, "currency": "usd"}

Under "Assign Variations Based on Attribute", choose a stable identifier, here id, which your server sets to a first-party visitor ID. Only attributes marked as identifiers can be used for assignment (feature flag experiments). Keep amounts in minor units, the way Stripe takes them. A number feature holding just the amount works too if the currency never changes.

Leave the weights alone once the test starts. GrowthBook recommends adjusting overall exposure instead of the split, because changing splits mid-experiment can move users between variations (feature flag experiments). JSON Schema validation for feature values is an Enterprise feature (feature basics), so on other plans your code has to reject a bad value before it reaches Stripe.

How do you evaluate the price on your server?

Create one GrowthBookClient when the server starts, log exposures in its tracking callback, and evaluate the feature per request with the visitor's attributes (Node.js SDK).

growthbook.ts
import { GrowthBookClient } from "@growthbook/growthbook";
import { db } from "./db"; // your Postgres client (node-postgres style)

export const gb = new GrowthBookClient({
  apiHost: "https://cdn.growthbook.io",
  clientKey: process.env.GROWTHBOOK_CLIENT_KEY!,
  trackingCallback: (experiment, result, user) => {
    // One row per exposure. GrowthBook's assignment query reads this table.
    void db.query(
      "INSERT INTO experiment_exposures (anonymous_id, experiment_id, variation_id) VALUES ($1, $2, $3)",
      [user.attributes?.id, experiment.key, result.key],
    );
  },
});

await gb.init({ timeout: 3000 }); // never throws; features evaluate to null until they load
price.ts
import { ExpressCookieStickyBucketService } from "@growthbook/growthbook";
import type { Request, Response } from "express";
import { gb } from "./growthbook";

const STANDARD = { amount: 2900, currency: "usd" };
const BOTS = /bot|crawl|spider|slurp|preview|facebookexternalhit|headless|lighthouse|curl|wget/i;

export async function priceFor(req: Request, res: Response, visitorId: string) {
  if (BOTS.test(req.get("user-agent") ?? "")) return STANDARD; // crawlers never enter the test

  // Pro and Enterprise: keep each visitor's first variation even if the experiment changes.
  const stickyBucketService = new ExpressCookieStickyBucketService({ req, res }); // needs cookie-parser
  const user = await gb.applyStickyBuckets({ attributes: { id: visitorId } }, stickyBucketService);

  const value = gb.getFeatureValue("pro-price", STANDARD, user) as { amount?: unknown; currency?: unknown };
  const amount = value.amount;
  if (typeof amount !== "number" || !Number.isInteger(amount) || amount < 1900 || amount > 4900) return STANDARD;
  if (value.currency !== "usd") return STANDARD;
  return { amount, currency: "usd" };
}

What to know about this code:

  • init() doesn't throw on network errors; until features load, every feature evaluates to null (JavaScript SDK), and getFeatureValue() returns the fallback you pass, here your current price.
  • The tracking callback runs when a visitor is enrolled in the experiment, which is the moment GrowthBook expects you to record the exposure in your warehouse (feature flag experiments). Since version 1.7.0 its third argument carries the attributes used for evaluation, and GrowthBook recommends logging those (JavaScript SDK).
  • The bot check runs first. GrowthBook assigns whatever ID it receives, so a crawler with a fresh cookie would be enrolled like a buyer.
  • Without a Pro plan, delete the two sticky-bucketing lines and pass { attributes: { id: visitorId } } straight to getFeatureValue().

How does GrowthBook keep a visitor on one price?

By hashing. GrowthBook hashes the assignment attribute together with the experiment's seed (the experiment key, unless you set one) using FNV-1a, turns the result into a number between 0 and 1, and maps that number onto the variation weights (SDK specification). The same ID under the same settings always lands on the same price, on any server, without a lookup.

The weak point is "the same settings". Change the weights and the ranges shift, so some visitors land in a different variation. Raising overall exposure only adds visitors, which is why GrowthBook suggests it instead of editing the split. For a feature, a moved visitor is a nuisance; for a price, a returning visitor sees a new number. You can avoid it in two ways:

  • Don't touch a running experiment. If a price is clearly broken, stop the experiment and start a new one.
  • Turn on sticky assignment. GrowthBook's sticky bucketing stores each visitor's first variation and keeps it after you change the experiment (sticky bucketing). On Node, ExpressCookieStickyBucketService keeps assignments in a cookie and RedisStickyBucketService keeps them in Redis.

With sticky bucketing on, you can also set a fallback attribute: hash on the user ID when someone is signed in and fall back to the anonymous ID when they aren't. The first variation a person gets then follows them across devices (sticky bucketing). On a pricing page, where most visitors are anonymous, the simplest setup is the one above: one first-party visitor ID, saved on the account at signup.

How do you charge the assigned price in Stripe?

Call priceFor() again in the checkout route and send the amount as inline price_data. The same ID returns the same variation, and the sticky cookie keeps it there even if you change the experiment in between.

checkout.ts
app.post("/checkout", async (req, res) => {
  const visitorId: string | undefined = req.cookies.vid;
  if (!visitorId) {
    res.redirect(303, "/pricing");
    return;
  }
  const price = await priceFor(req, res, visitorId); // never trust an amount sent by the browser
  const tags = { visitor_id: visitorId, price_amount: String(price.amount) };

  const session = await stripe.checkout.sessions.create({
    mode: "payment",
    line_items: [{ quantity: 1, price_data: { currency: price.currency, unit_amount: price.amount, product_data: { name: "Pro" } } }],
    client_reference_id: visitorId,
    metadata: tags,
    payment_intent_data: { metadata: tags },
    success_url: "https://example.com/thanks",
    cancel_url: "https://example.com/pricing",
  });
  res.redirect(303, session.url!);
});

Your Stripe webhook then stores each paid session and each refund in a price_orders table keyed by PaymentIntent, with the visitor ID from metadata and amounts before tax. The handler in how to A/B test prices on Stripe does exactly that, including charge.refunded.

How do you analyze revenue per visitor in GrowthBook?

Point GrowthBook at two queries: an assignment query that says who saw which variation, and a fact table that says how much each visitor paid. A mean metric over that fact table is your revenue per visitor.

The experiment assignment query must return an identifier column, timestamp, experiment_id and variation_id, with one row per exposure (data sources):

Experiment assignment query
SELECT
  anonymous_id,
  received_at AS timestamp,
  experiment_id,
  variation_id
FROM experiment_exposures

A fact table is a SQL SELECT with a timestamp column and one column per identifier type (fact tables). Net refunds out inside it:

Fact table: price_orders
SELECT
  created_at AS timestamp,
  visitor_id AS anonymous_id,
  net * (gross - refunded)::numeric / NULLIF(gross, 0) / 100 AS revenue
FROM price_orders
WHERE livemode

Then create a mean metric with SUM(revenue) per user. GrowthBook's docs describe a "Revenue per User" metric built this way (fact tables), and averaging it over every exposed visitor, buyers or not, gives revenue per visitor. Because GrowthBook runs these queries again each time results update, a refund recorded next week lowers the original order's revenue in the next analysis.

Two metric settings decide whether that holds. Keep the metric window at "None", the default for fact metrics, so purchases and refunds count until the experiment ends rather than only inside a conversion window. If you add percentile capping, check that the cap lands above your highest test price, or it trims exactly the revenue you're testing (metrics).

GrowthBook defaults to Bayesian statistics and also offers frequentist analysis, where sequential testing reduces the cost of peeking; CUPED is available in both. In Bayesian mode, you typically wait until the chance to win reaches 95%, or 5% if the variation is worse (statistics overview). Decide the minimum number of purchases per variation before launch, too.

No warehouse yet? GrowthBook Cloud's Managed Warehouse is a hosted ClickHouse that the SDKs fill with experiment views automatically. You send purchases through its Ingestion API, at up to 100 events per request and 1 request per second (Managed Warehouse). As of November 2026, Starter includes 1 million events a month and Pro 2 million, then $30 per million (GrowthBook pricing).

Does GrowthBook offer multi-armed bandits, and should you use one for prices?

Yes, on Pro and Enterprise. GrowthBook's bandit uses Thompson sampling, which allocates traffic in proportion to each variation's probability of being best, and keeps every variation at 1% or more in case behavior changes (bandits overview). It optimizes a single decision metric, requires at least 100 users per variation before it reweights, and recommends 40 conversions per variation first (bandit configuration). You choose an update cadence of 15 minutes or longer, and GrowthBook suggests daily or slower (bandit configuration).

Illustration: what Thompson sampling believes about three prices after 1,500 visitors each.

What that means for a price test:

  • Revenue per user can be the decision metric. GrowthBook rules out quantile metrics as the decision metric and funnel metrics anywhere on a bandit (bandit configuration); a mean metric is neither.
  • Purchases arrive late. GrowthBook wants conversions to happen in a window much shorter than the update cadence (bandit configuration), but a pricing-page visitor may buy days later and ask for a refund weeks later. Each update then judges prices partly on visitors who haven't decided yet.
  • Every update waits on your pipeline: events have to reach your warehouse and then GrowthBook's queries before weights move (bandit configuration). Ingestion delay sets the real cadence.
  • Sticky bucketing is effectively required. Without it, a returning visitor can see a different variation after a weight update while GrowthBook still credits their conversions to the first one (bandit configuration). For a price, that is a customer who saw $29 on Monday and $39 on Friday.
  • Use three or more prices. GrowthBook notes that with only two arms a bandit can be worse than a standard experiment at finding the better variation quickly (bandits overview).
  • Count the wait. Example: with 20 purchases a day spread over three prices, the recommended 40 conversions per variation means 120 purchases, or about 6 days, before the first reweighting is worth making (40 × 3 ÷ 20).
  • Bandit estimates can be biased. If you need a clean estimate of how much more $39 earns than $29, GrowthBook recommends a standard experiment (bandits overview).

For the theory behind the allocation, see Thompson sampling for pricing.

What are the gaps when you test prices with GrowthBook?

GrowthBook covers assignment and statistics. A price test needs more around them, and each gap below is code or configuration you own.

Pricing needWhat GrowthBook gives youWhat you add
Crawlers see the standard priceAssigns any ID it receivesA user-agent check before evaluation
Same price on the page and at checkoutSame answer while the experiment's settings stay the sameSticky bucketing (Pro) or an untouched experiment
Revenue matches StripeAnalyzes the rows in your warehouseA webhook handler and a pipeline into the warehouse
Refunds count against the priceWhatever your fact table nets outRefund handling in that table
A bandit that reacts to salesUpdates no faster than your data arrivesFast ingestion and a short conversion window
Guardrails on the amountJSON validation on EnterpriseBounds checks in code

How does Leverprice handle those gaps?

Leverprice is built only for the price part. Your server calls getPrice(), which keeps each visitor on one price through a signed first-party cookie by default (and the same bucket on every device with userId), gives crawlers, link previews and monitors your standard price without enrolling them, and checks every price against your own minPrice and maxPrice before returning it, with your fallback price if anything fails.

Revenue comes from your provider's signed webhooks, from Stripe, Polar, Lemon Squeezy or Dodo Payments, so no warehouse pipeline sits between a sale and the engine. On Pro, a Thompson-sampling bandit models each visitor as a kept purchase, a refunded purchase or no purchase, so refunds count against a price directly. It recomputes weights every few minutes, counts only visitors older than 30 minutes, and keeps at least 5% of traffic on every price. GrowthBook remains the better choice if you already run a warehouse and test much more than prices; the comparison page walks through the trade-offs, and the docs show the install.

Frequently asked questions

Can I self-host GrowthBook for a price test?

Yes. The open-source version runs on your own servers for free and covers features and experiments. Sticky bucketing and bandits are paid features, and GrowthBook's paid self-hosted option is Enterprise (GrowthBook pricing).

Does GrowthBook connect to Stripe directly?

GrowthBook's docs describe metrics as SQL over your data source, so Stripe revenue has to reach your warehouse, or the Managed Warehouse, first. The usual path is your Stripe webhook writing purchases and refunds to a table, as shown above.

Should the hash attribute be a user ID or an anonymous ID?

For a pricing page, an anonymous first-party ID, because most visitors aren't signed in when they see the price. With sticky bucketing you can hash on the user ID and fall back to the anonymous ID, and the first variation follows the person across devices.

Is a number feature enough, or do I need JSON?

A number feature holding the amount in cents is enough if you sell in one currency. JSON lets one value carry the amount and the currency, which your code can check together before calling Stripe.

How many visitors does a GrowthBook bandit need?

At least 100 users per variation before the first reweighting, and GrowthBook recommends 40 conversions per variation (bandit configuration). At low traffic that can take weeks, which is where price testing with low traffic helps.