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:
- Create a new experiment
- Define variants (e.g., “control” and “variant-a”)
- Set traffic split percentages
- 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
Fromsrc/ab-testing.ts:28-66, variant assignment is deterministic and sticky:
How Assignment Works
- User identified by
userId(if logged in) oranonymousId - Hash generated from user ID + experiment key (deterministic)
- Variant selected based on hash and traffic splits
- 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
- Check experiment status is
RUNNING - Verify
trafficSplit> 0 - Ensure experiment key matches exactly
- Check user is identified (has userId or anonymousId)
Variant Keeps Changing
Assignments should be sticky. If changing:- Check userId/anonymousId is consistent
- Verify browser storage is enabled
- Don’t use
forceRefreshoption unless needed
Conversions Not Tracking
- Verify user has an active assignment
- Check experiment is still running
- Enable debug mode to see conversion events
- Ensure
trackConversionis called after assignment loads