---
title: "How to A/B Test an Onboarding Flow in Next.js"
description: "Onboarding tests span multiple pages and often multiple sessions, which breaks the single-page assumption most A/B testing advice makes. Here's what actually works."
canonical: https://landtest.dev/blog/ab-test-onboarding-flow-nextjs
last-updated: 2026-10-30
---

# How to A/B Test an Onboarding Flow in Next.js

> Onboarding tests span multiple pages and often multiple sessions, which breaks the single-page assumption most A/B testing advice makes. Here's what actually works.

A/B testing an onboarding flow in Next.js requires solving a problem single-page landing page tests don't have: the variant spans multiple routes, often multiple sessions, and the user needs to stay in the same variant across all of them. Assignment logic scoped to a single page load isn't enough — you need a persistent identifier that survives navigation, tab closes, and return visits, and a way to measure completion across the whole flow rather than click-through on any individual step.

## Assignment has to survive the full flow

A cookie set on the first onboarding step needs to be read consistently on every subsequent step, including if the user closes the tab and comes back later. This rules out session-only assignment for anything but the shortest flows, and it means the variant check needs to happen consistently across every route in the flow, not just the entry point.

```ts
// lib/onboarding-variant.ts — read once, persist for the whole flow
export function getOnboardingVariant(req: Request): "control" | "variant-b" {
  const existing = getCookie(req, "onboarding_variant");
  if (existing) return existing as "control" | "variant-b";
  // assign once, persist with a long-lived cookie covering the full flow
}
```

## Measure full completion, not step-by-step click-through

An onboarding variant that improves click-through on step one but decreases overall completion has moved the friction later, not removed it — the same trap as signup page testing, amplified by having more steps for friction to hide in. Track completion of the entire flow as the primary metric, with per-step drop-off as a diagnostic for understanding where a variant is winning or losing, not as the metric you optimize directly.

## Handle partial completion carefully

A user who starts the flow in variant B, completes two of four steps, and returns a week later needs to either continue in variant B or the test needs an explicit policy for what happens — reassigning mid-flow is close to never correct, since it mixes the experience in a way that invalidates the comparison for that user. Decide this explicitly rather than letting it happen as a side effect of how the assignment cookie happens to expire.

## Account for cohort effects in your analysis window

Onboarding flows often need the test to run for long enough to capture how the cohort behaves in the following days or weeks, not just whether they complete the immediate flow — a variant that improves immediate completion but produces lower-quality activated users needs a longer observation window to catch. Factor that into your test time-box before committing to a shorter one that only measures the immediate step.

## FAQ

**How do I keep A/B test assignment consistent across a multi-step onboarding flow?**
Use a persistent identifier (a long-lived cookie or account-linked flag) set once at flow entry and read consistently across every route in the flow, not a session-scoped check per page.

**What should I measure in an onboarding A/B test?**
Full flow completion as the primary metric, with per-step drop-off as a diagnostic — optimizing individual step click-through alone can hide friction that's just moved to a later step.

**What happens if a user returns mid-flow after variant assignment?**
Keep them in the same variant they started in. Reassigning mid-flow mixes two experiences for one user and invalidates the comparison.

---

Related: [A/B test a signup page in Next.js](/blog/ab-test-signup-page-nextjs) · [Best A/B testing tools for Next.js developers](/blog/best-ab-testing-tools-nextjs-developers) · [Landtest for A/B testing](/ab-testing)
