Prompt

How do I do server-side A/B testing for a SaaS product?

Technology / AB Testing & Experimentation1 observationLast seen Oct 13, 2026

Latest observation

Oct 13, 2026OpenAI APIWeb search: off

Server-side A/B testing for a SaaS product usually means the backend decides which variant a user sees, and the frontend just renders whatever the server returns. This is a good fit when you want reliable assignment, avoid client-side flicker, and test things like pricing, onboarding flows, recommendations, or backend logic.

1) What “server-side A/B testing” looks like

Typical flow:

  1. User requests a page or hits an API.
  2. Your server identifies the user.
  3. Server assigns the user to a variant using a deterministic rule.
  4. Server stores that assignment.
  5. Server returns the appropriate content/behavior.
  6. You log exposure and later measure outcomes.

Example variants:

  • A: current onboarding flow
  • B: simplified onboarding flow

2) Core requirements

You need:

  • Stable user identifier
    e.g. user ID, account ID, anonymous cookie ID
  • Experiment definition
    • experiment key
    • variants and allocation percentages
    • start/end dates
    • target audience rules
  • Assignment logic
  • Persistent storage for assignments/exposures
  • Event tracking for exposures and conversions
  • Analysis pipeline to compare outcomes

3) Recommended assignment strategy

Use deterministic bucketing so the same user always gets the same variant.

A common approach:

  • Hash experiment_key + user_id
  • Map hash to a number 0–99 or 0–9999
  • Use ranges to assign variants

Example:

  • 0–49 → A
  • 50–99 → B

This makes assignment:

  • repeatable
  • scalable
  • consistent across services

4) Simple server-side implementation pattern

Pseudocode

def assign_variant(experiment_key, user_id):
    bucket = hash(experiment_key + ":" + user_id) % 100

    if bucket < 50:
        return "A"
    else:
        return "B"

If you need 90/10 or 80/20 splits, adjust the thresholds.

Better practice

Use a stable hash function like:

  • MurmurHash
  • SHA-256
  • xxHash

Avoid language-native hash functions if they are not stable across runs.

5) Persist the assignment

Even with deterministic hashing, it’s often useful to store assignments in a database or feature flag system for:

  • auditability
  • re-use
  • forced overrides
  • experiment changes

Example table:

user_idexperiment_keyvariantassigned_at
123onboarding_v2B2026-10-13

6) Track exposure and conversion

You need at least two event types:

Exposure event

When the user is actually shown variant B.

Fields:

  • user_id
  • experiment_key
  • variant
  • timestamp
  • request/page/context

Conversion event

When the user completes the desired action.

Fields:

  • user_id
  • experiment_key
  • variant
  • timestamp
  • event_type
  • value if relevant

Important: measure conversions only after exposure.

7) Avoid common mistakes

Don’t assign based on session alone if you want stable user-level tests

A user could switch variants across sessions.

Don’t let frontend decide if you need strict control

That can introduce:

  • flicker
  • manipulation
  • inconsistent assignments

Don’t change allocations mid-test casually

Changing from 50/50 to 80/20 can complicate interpretation unless you know what you’re doing.

Don’t stop the test too early

You’ll inflate false positives if you peek too often.

Don’t test multiple overlapping experiments on the same dimension without a plan

Example: two experiments both affecting pricing can interact.

8) Handle targeting and exclusions

You often want rules like:

  • only paid users
  • only new signups
  • exclude employees/internal traffic
  • exclude users in certain countries

Example:

if user.is_employee or user.plan != "free":
    return None

Or more structured:

  • eligibility check
  • assignment check
  • exposure logging

9) Recommended architecture

A practical SaaS setup:

  • Experiment config service
    Stores experiment definitions and variant weights
  • Assignment service or library
    Determines variant for a user
  • Event pipeline
    Sends exposures and conversions to analytics/warehouse
  • Analysis layer
    SQL notebooks, dbt models, or statistical scripts

For many SaaS teams, a lightweight in-house system is enough to start.

10) Minimal database schema

experiments

  • id
  • key
  • name
  • status
  • start_at
  • end_at

experiment_variants

  • experiment_id
  • variant_key
  • allocation_percentage

experiment_assignments

  • user_id
  • experiment_key
  • variant_key
  • assigned_at

experiment_events

  • id
  • user_id
  • experiment_key
  • variant_key
  • event_type (exposure, conversion)
  • created_at
  • metadata JSON

11) How to analyze results

Compare metrics between groups:

  • conversion rate
  • activation rate
  • retention
  • revenue per user
  • churn

For each variant:

  • count exposed users
  • count conversions
  • calculate lift
  • test statistical significance

Example:

  • A: 10% conversion
  • B: 12% conversion
  • uplift = 2 percentage points

If you want rigor, use:

  • chi-square / z-test for proportions
  • t-test for continuous metrics
  • Bayesian methods if preferred

12) If your SaaS has multiple surfaces

You may need different approaches for:

  • web app
  • API responses
  • email onboarding
  • pricing page
  • mobile app

The key is to keep the assignment source of truth centralized so the same user gets the same variant across channels when appropriate.

13) Practical starter approach

If you want to implement this quickly:

  1. Pick one experiment
  2. Define one user identifier
  3. Use deterministic hashing for assignment
  4. Store assignments in the DB
  5. Log exposure when variant is rendered
  6. Track one conversion metric
  7. Analyze in SQL

14) Example end-to-end flow

User visits onboarding:

  • backend checks eligibility
  • assigns experiment onboarding_v2
  • user hashes to variant B
  • server returns B onboarding flow
  • exposure event logged
  • user completes signup
  • conversion event logged
  • analysis compares A vs B

15) Tools you can use

Build it yourself:

  • backend library + Postgres + analytics warehouse

Or use tools like:

  • LaunchDarkly
  • Statsig
  • Split
  • Optimizely
  • GrowthBook

These can handle assignment, targeting, logging, and analysis, though you should still understand the methodology.

If you want, I can also give you:

  1. a production-ready backend design,
  2. a PostgreSQL schema + SQL analysis queries, or
  3. an example implementation in Python/Node/Go.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.