Skip to main content

Overview

A/B testing (also called split testing) lets you test different versions of features, UI elements, or flows to determine which performs better. The MentiQ SDK provides built-in A/B testing capabilities with automatic variant assignment and conversion tracking.

Quick Start

1

Enable A/B Testing

Set enableABTesting: true in your analytics configuration:
2

Create Experiment in Dashboard

In your MentiQ dashboard:
  1. Create a new experiment
  2. Define variants (e.g., “control” and “variant-a”)
  3. Set traffic split percentages
  4. Start the experiment
3

Get Variant Assignment

Use the useABTest hook to get the assigned variant:
4

Track Conversions

Track when users complete the goal of your experiment:

Core Concepts

Experiments

An experiment tests different variations of a feature:

Variants

Each experiment has multiple variants (including a control):

Assignment

When a user is assigned to an experiment:

Using the useABTest Hook

Assignment Logic

From src/ab-testing.ts:28-66, variant assignment is deterministic and sticky:

How Assignment Works

  1. User identified by userId (if logged in) or anonymousId
  2. Hash generated from user ID + experiment key (deterministic)
  3. Variant selected based on hash and traffic splits
  4. Assignment cached to ensure consistency
Assignments are sticky—once a user is assigned to a variant, they stay in that variant even if you change traffic splits.

Tracking Conversions

Simple Conversion

Conversion with Value

Multiple Conversion Events

Track different conversion types in the same experiment:

Use Cases

Testing Button Copy

Testing Pricing

Testing Onboarding Flows

Testing UI Layouts

Advanced Usage

Checking Specific Variant

Multiple Experiments

Programmatic Variant Check

Best Practices

A/B Testing Tips:
  • Run one test at a time per page/feature to avoid interaction effects
  • Define success metrics before starting
  • Run experiments for at least 1-2 weeks to account for weekly patterns
  • Ensure sufficient sample size (typically 1000+ users per variant)
  • Don’t stop experiments early—wait for statistical significance
  • Document what you’re testing and why
  • Clean up old experiments regularly

Statistical Significance

Don’t make decisions based on small sample sizes:

Troubleshooting

Assignment Always Returns Null

  1. Check experiment status is RUNNING
  2. Verify trafficSplit > 0
  3. Ensure experiment key matches exactly
  4. Check user is identified (has userId or anonymousId)

Variant Keeps Changing

Assignments should be sticky. If changing:
  1. Check userId/anonymousId is consistent
  2. Verify browser storage is enabled
  3. Don’t use forceRefresh option unless needed

Conversions Not Tracking

  1. Verify user has an active assignment
  2. Check experiment is still running
  3. Enable debug mode to see conversion events
  4. Ensure trackConversion is called after assignment loads