Why classic multi-armed bandits fail in CRO — and how a cohort-based, delay-aware framework can actually self-optimise your experiments over time.

For years, product and growth teams have been sold the dream of auto-optimising experiments — systems that continuously reallocate traffic to the best-performing variation, reducing the cost of a long A/B test and maximising uplift as early as possible.

Most of these systems are based on the multi-armed bandit (MAB) model. On paper, bandits are brilliant: you give more weight to winners, reduce exposure to losers, and statistically minimise regret.

But there’s an uncomfortable truth:

Classic multi-armed bandits simply do not work out of the box for online experimentation. They are built for a mathematical world that doesn’t match real user behaviour.

Why multi-armed bandits fail in online experiments

1. Bandits assume immediate rewards — websites don’t

In the classic MAB problem:

  • You pull a lever.
  • You receive a reward within seconds.
  • You update your beliefs immediately.

This “instant feedback loop” is fundamental to how MABs converge. The algorithm expects the outcome of each decision to be revealed almost immediately.

Online experiments are very different:

  • A user sees Variant A today.
  • Adds something to basket tomorrow.
  • Returns again next week.
  • Converts (or not) days later.

The reward is delayed, sparse, and often tied to attribution windows, not immediate actions. That breaks a core assumption of the multi-armed bandit model.

2. Bandits assume the algorithm directly causes the reward

In a casino, the “reward” is generated solely by the lever the user pulls. The environment is simple: your choice of arm causes the outcome distribution.

Online, it’s messier:

  • The user decides whether they convert.
  • Behaviour is influenced by channel, seasonality, prior sessions, intent and context.
  • The experiment only nudges the outcome; it doesn’t fully generate it.

Because the reward is not a clean function of the “arm” alone, the classic bandit maths no longer fits neatly.

3. Return-user bias destroys naive adaptive allocation

Return users almost always convert at a higher rate than first-time visitors. If a variation accidentally attracts more returning users early on:

  • The bandit thinks it’s winning.
  • It aggressively shifts traffic toward that variant.
  • The imbalance grows further.
  • The final outcome is heavily distorted.

This return-user bias is one of the main reasons “self-optimising” systems can look great in-flight but fail to generalise.

Does Optimizely fix this problem?

Optimizely’s Stats Engine and auto-allocate features are often perceived as solving these issues. They help, but they don’t make the underlying constraints disappear.

What Optimizely gets right

  • Sticky assignments: once a user is bucketed into a variation, they stay there for that experiment. Optimizely does not reassign existing users.
  • Weights only change for new users: adaptive allocation affects future traffic, not past participants.
  • Empirical Bayesian statistics: the Stats Engine reduces some bias from unequal sample sizes and repeated looks at the data.

What Optimizely does not fully solve

  • Return users still convert at different rates than new users.
  • Variants may change how often users return, not just whether they convert.
  • Conversion delays still distort the signal used to update weights.
  • Seasonality and traffic mix shifts can still bias adaptive decisions.

So while platforms like Optimizely avoid the worst sins (like reassigning users), they are still constrained by delayed rewards and behavioural complexity.

A better approach: cohort-based adaptive experimentation

There is a way to build a self-optimising online experiment that respects real-world constraints:

Cohort-based, delayed-reward, Bayesian adaptive experimentation with explicit adjustment for return-user behaviour — a form of Bayesian sequential test with standardisation.

It sounds academic, but the operational idea is straightforward.

1. Assign traffic by daily cohorts

Each day:

  • All new users are randomly assigned to variants A/B/C using that day’s weights.
  • This set of users forms a daily cohort.
  • Once a user is in a variant, they never move for the life of the experiment.

2. Only analyse fully matured cohorts

Suppose you’re using a 7-day conversion window. On day T:

  • Only cohorts from days ≤ T − 7 are used to update weights.
  • No partially observed users influence the allocation decisions.

This avoids bias from delayed conversions and changing attribution windows.

3. Adjust for return-user bias mathematically

Instead of just comparing raw conversion rates, you explicitly model conversion as a function of return behaviour.

For each variant v, you estimate:

  • pv,1 — conversion probability on first visit
  • pv,2 — conversion probability on second visit
  • pv,k — and so on for each visit number k within your window

Then you define a common visit-count distribution across variants — say qk = probability that a user has exactly k visits within the window. For example:

  • Use the pooled distribution across all variants, or
  • Fix a historical “typical” profile for your site.

You can then compute a standardised conversion rate for each variant:

// Conceptual formula
tilde_p_v = Σ_k ( p_v,k * q_k )

This answers the question: “What would this variant’s conversion rate be if it saw the same mix of new and returning users as every other variant?”

That’s your bias-adjusted performance estimate.

4. Use Bayesian updating to adjust tomorrow’s weights

Once you have a standardised conversion estimate for each variant, you:

  • Update a Bayesian posterior for each variant’s true performance.
  • Allocate tomorrow’s traffic using those posteriors (e.g. via Thompson Sampling or a softmax over expected lift).
  • Only apply new weights to new users coming in tomorrow.

The result:

  • No user is ever reassigned.
  • Delayed conversions are respected via cohort maturity.
  • Return-user bias is explicitly corrected for.
  • The experiment self-optimises over time in a mathematically defensible way.

Cloudflare Worker example: routing traffic by variant

Below is a simplified Cloudflare Worker script that demonstrates how you might implement the “front door” of this system. It doesn’t do the nightly Bayesian updating (that would typically run in a backend job), but it:

  • Reads experiment weights from KV (set nightly by your optimisation job).
  • Assigns new users to a variant based on those weights.
  • Persists the assignment in a cookie (no reassignment).
  • Optionally tags the request/response so your site can render the right variant.
// Example Cloudflare Worker for cohort-based variant assignment
// -------------------------------------------
// Prereqs:
// 1) Bind a KV namespace called "EXPERIMENT_WEIGHTS" in your worker.
// 2) Have a nightly job update keys like "my-experiment-1" with JSON:
//    { "A": 0.5, "B": 0.5 } or { "A": 0.2, "B": 0.8 }, etc.
// 3) Your site/app uses the "x-experiment-variant" header or cookie
//    to decide which variant to render.

export default {
  async fetch(request, env, ctx) {
    const EXPERIMENT_KEY = "my-experiment-1";
    const COOKIE_NAME   = "exp_" + EXPERIMENT_KEY;
    const url           = new URL(request.url);

    if (url.pathname.startsWith("/static") || url.pathname.startsWith("/api")) {
      return fetch(request);
    }

    const cookieHeader = request.headers.get("Cookie") || "";
    const existingVariant = getCookieValue(cookieHeader, COOKIE_NAME);

    let variant;
    if (existingVariant) {
      variant = existingVariant;
    } else {
      const weightsJson = await env.EXPERIMENT_WEIGHTS.get(EXPERIMENT_KEY);
      let weights;
      try { weights = weightsJson ? JSON.parse(weightsJson) : null; } catch (e) { weights = null; }
      if (!weights || Object.keys(weights).length === 0) {
        weights = { A: 0.5, B: 0.5 };
      }
      variant = chooseWeightedVariant(weights);
    }

    const requestWithVariant = new Request(request);
    requestWithVariant.headers.set("x-experiment-key", EXPERIMENT_KEY);
    requestWithVariant.headers.set("x-experiment-variant", variant);

    let response = await fetch(requestWithVariant);
    response = new Response(response.body, response);
    response.headers.append("Set-Cookie", `${COOKIE_NAME}=${variant}; Path=/; Max-Age=15552000; SameSite=Lax`);
    response.headers.set("x-experiment-variant", variant);

    return response;
  }
};

function chooseWeightedVariant(weights) {
  const entries = Object.entries(weights);
  if (entries.length === 0) return "control";
  const total = entries.reduce((sum, [, w]) => sum + Number(w || 0), 0);
  const r = Math.random() * total;
  let acc = 0;
  for (const [variant, weight] of entries) {
    acc += Number(weight || 0);
    if (r <= acc) return variant;
  }
  return entries[entries.length - 1][0];
}

function getCookieValue(cookieHeader, name) {
  const cookies = cookieHeader.split(";").map(c => c.trim());
  for (const cookie of cookies) {
    if (!cookie) continue;
    const [k, v] = cookie.split("=");
    if (k === name) return v;
  }
  return null;
}

With this Worker in place, you can:

  • Run your nightly Bayesian/cohort logic in a backend script (Python, R, SQL, etc.).
  • Write updated weights to Cloudflare KV each night.
  • Let the Worker do the real-time bucketing at the edge for all new users.
  • Use your analytics pipeline (e.g. GA4, Snowflake, BigQuery) to model visit-level behaviour and return-user effects.

That’s the practical backbone of a self-optimising, cohort-based experimentation system that respects delayed conversions and return behaviour.

Conclusion

The dream of “self-optimising web experiments” is achievable — but not with naive multi-armed bandits that assume instant, algorithm-generated rewards.

Real websites have:

  • Delayed, multi-visit conversion paths.
  • New vs returning behaviour differences.
  • Seasonal shifts and changing traffic mixes.

A cohort-based, delay-aware, bias-corrected Bayesian framework acknowledges this reality and still gives you the benefits of auto-optimisation:

  • More traffic allocated to better variants over time.
  • No reassignment of existing users.
  • Explicit handling of return-user bias.
  • Clean separation between front-door routing (e.g. Cloudflare Workers) and back-end optimisation logic.

If you’re currently relying on vanilla bandits or black-box “auto-optimise” toggles, this is the next step: a system designed for the web you actually have, not the casino the maths was originally written for.