All posts
· 5 min read

Designing A/B Testing for a Server-Driven UI

When the server already composes every screen, a variant is just a different presenter. The hard parts are elsewhere: stable assignment, honest exposure logging, and making sure a variant never reaches an app that can't render it. A design write-up, before the first experiment runs.

This is a design post. The experimentation service exists and is deployed to every environment, but no experiment has run on it yet. This is the design we’re building toward and the reasoning behind it. A follow-up will cover what the first real experiment taught us.

Our Server-Driven UI framework moved screen composition to the backend. The BFF decides which components appear, in what order, with what copy and actions, and the iOS, Android and web clients render whatever arrives. One consequence was clear from the start: if the server builds the screen, the server can build two versions of it.

That makes the obvious part of A/B testing trivial. The rest of this post is about the parts that aren’t.

A variant is just a presenter

In a client-driven app, an experiment means shipping both variants in the binary, gating them with a flag, and waiting for adoption before you have enough traffic. In our setup, a screen is the output of a presenter function on the BFF. A variant is a second presenter:

// Illustrative sketch
async function createPaymentScreen(args: PaymentArgs) {
  const variant = await experiments.variantFor('payment-create-banner', args.user);

  return variant === 'treatment'
    ? createPaymentPresenterWithBannerFirst(args)
    : createPaymentPresenter(args);
}

No client release, no flag inside the app, no waiting for adoption. You can start a variant, change it, or kill it with a backend deploy. That’s the payoff.

Assignment: deterministic, not stored

Assignment has to be stable: the same user sees the same variant on every request, on every device, for the whole experiment. The simplest way to guarantee that without a database lookup on the hot path is to hash:

bucket = hash(experimentId + userId) mod 100
variant = bucket < 50 ? "control" : "treatment"

Including the experiment ID in the hash means a user’s bucket in one experiment says nothing about their bucket in another, so experiments don’t correlate with each other. The experimentation service stores experiment definitions (allocation, eligibility rules, start and end, kill switch) rather than per-user assignments. BFFs cache those definitions, so choosing a variant is a local computation, not a network call in the middle of a payment.

The SDUI-specific trap: variants that can’t render

This is the part generic A/B guides don’t cover. With server-driven UI, a treatment often uses a newer component: a different banner, a new card layout. Partner banking apps update on their own schedule, so some fraction of users are always on an app version that can’t render it.

If assignment ignores that, two bad things happen. Older clients get a payload they can’t decode, which is exactly the kind of crash we already hit once during the platform migration. Or, if the BFF silently falls back to control for those users, the treatment group ends up made only of users on newer apps. That’s a different population, and the results are biased before the experiment starts.

The fix is to make renderability part of eligibility, checked before assignment. The SDUI platform already negotiates a contract version with every client and can assert that a payload is renderable at that version. Experiment definitions declare the minimum contract version their treatment needs. Users below it are excluded from the experiment entirely, not quietly put in control. Both groups then come from the same population.

Exposure is when it renders, not when it’s assigned

A user is assigned the moment we compute their bucket. They’re exposed only when the variant screen is actually served. If you analyze by assignment, you include users who never reached the screen, which dilutes the effect toward zero.

SDUI screens already carry analytics events. The design adds the experiment ID and variant to the screen’s events at render time, so exposure and outcome come from the same events:

  • Exposure: the variant screen’s view event, tagged with experimentId and variant
  • Outcome: a downstream event we already emit, such as successful authorization for a payment flow

Conversion is outcome events divided by exposure events, for each variant, using event data the platform already collects.

Guardrails

  • Kill switch. Every experiment can be turned off immediately from its definition, which sends everyone back to control. No deploy needed.
  • Fail to control. If definitions can’t be loaded, the BFF serves control. An experiment must never be the reason a payment screen fails.
  • Sample ratio mismatch check. If a 50/50 experiment shows 53/47 exposures, something upstream is broken, often eligibility or a crash in one variant. Check the ratio before reading any result.
  • Holdout. A small slice of users is kept out of all experiments, to measure the combined effect of everything shipped through experimentation.
  • Payment-path budget. Choosing a variant is local and cached, so it adds no network latency to a flow where every millisecond shows up in conversion.

What we’ll test first

The merchant payment flow is a natural first candidate. It’s fully server-driven, it already emits authorization events, and its creation screen has elements (promotion banners, merchant details, copy) whose placement is a product question rather than an engineering one. A simple first experiment, like where the promotion banner sits on the payment creation screen, would test the whole pipeline before anything more ambitious.

What I expect to learn

The parts I’m least sure of are on the analysis side, not the infrastructure: how much traffic a payment-flow experiment needs to detect a realistic effect, and how often the contract-version exclusion will shrink the eligible population. That’s what the follow-up will cover, with real numbers.