Related articles: Also see validating the performance impact of your A/B test variants, the frontend testing landscape A/B testing frameworks sit inside, and performance testing the variants your A/B framework serves.
A/B Testing Frameworks for Frontend: 5 Options That Drive Real Conversion Lifts
"Should we make the CTA button green or blue?" "Will a simplified checkout flow increase conversions?" "Does the new dashboard layout confuse or delight users?"
These questions are not just design debates�they are hypotheses that can be scientifically tested. A/B testing (also called split testing) is the practice of running controlled experiments on your users to determine which variation of a feature performs better. Instead of relying on intuition or the loudest voice in the room, you let data drive your decisions.
For frontend developers, implementing A/B tests and feature flags is not just a "nice to have"�it's a critical skill for any product-driven engineering team. Whether you're a startup founder, a QA engineer validating new features, or a full-stack developer optimizing conversion rates, understanding how to build and manage experiments is essential.
In this guide, we'll cover:
- The fundamentals of A/B testing and feature flags
- Implementation patterns: client-side vs. server-side
- Popular tools and frameworks (LaunchDarkly, Optimizely, GrowthBook, Unleash)
- How to measure statistical significance
- Ethical and UX considerations
By the end, you'll have a blueprint for running experiments in production�safely, scalably, and responsibly.
What is A/B Testing?
A/B testing is a method of comparing two (or more) versions of a web page, feature, or user experience to determine which one performs better against a predefined metric (e.g., click-through rate, conversion rate, time on page).
In an A/B test:
- Control (A): The current version (baseline).
- Variant (B): The new version you want to test.
Users are randomly assigned to either group, and you measure the difference in behavior. If the variant performs significantly better, you roll it out to everyone. If not, you keep the control or try a different approach.
Key Metrics for A/B Tests
| Metric | Description | Use Case |
|---|---|---|
| Conversion Rate | % of users who complete a desired action | Signup flows, checkout, CTA buttons |
| Click-Through Rate | % of users who click on a specific element | Banners, links, navigation items |
| Bounce Rate | % of users who leave without interaction | Landing pages, onboarding flows |
| Time on Page | Average time users spend on a page | Content engagement, educational content |
| Revenue Per User | Average revenue generated per user | E-commerce, SaaS pricing experiments |
What are Feature Flags?
Feature flags (also called feature toggles) are boolean switches that enable or disable features at runtime, without deploying new code. They are the foundational building block for:
- A/B testing (toggle different variations)
- Canary releases (gradually roll out to a small percentage of users)
- Kill switches (disable problematic features instantly)
- Progressive rollouts (release to 1%, then 5%, then 50%, then 100%)
Simple Feature Flag Example
const featureFlags = {
newCheckoutFlow: false,
aiChatbot: true,
darkMode: true,
};
if (featureFlags.newCheckoutFlow) {
renderNewCheckout();
} else {
renderOldCheckout();
}
While this works for local development, production systems require dynamic flags that can be toggled remotely without redeploying the application.
Client-Side vs. Server-Side A/B Testing
Client-Side A/B Testing
How it works: JavaScript running in the browser determines which variation to show.
Pros:
- Easy to implement (no backend changes)
- Works with static sites and JAMstack architectures
- Can test UI/UX changes instantly
Cons:
- Flash of unstyled content (FOUC) as the page loads and the variant is applied
- SEO concerns (Google may see the control, users may see the variant)
- Slower for low-bandwidth users
- Vulnerable to ad blockers and privacy tools
Example with a Simple Toggle:
// Feature flag service (e.g., from an API or localStorage)
const variant = getFeatureFlag('hero-button-color'); // returns 'control' or 'blue' or 'green'
const button = document.querySelector('#cta-button');
if (variant === 'green') {
button.style.backgroundColor = '#00FF00';
} else if (variant === 'blue') {
button.style.backgroundColor = '#0000FF';
} else {
// control: default color
}
Server-Side A/B Testing
How it works: The server decides which variation to render before sending HTML to the client.
Pros:
- No FOUC
- Better SEO (consistent content per user)
- Works for personalized experiences (e.g., pricing, product recommendations)
- More secure (no client-side manipulation)
Cons:
- Requires backend infrastructure
- More complex to implement
- Harder to test UI-only changes
Example in Next.js (App Router):
// app/page.tsx
import { cookies } from 'next/headers';
async function getFeatureFlag(userId: string, flagName: string) {
const response = await fetch(`https://feature-flag-service.com/flags?user=${userId}&flag=${flagName}`);
const data = await response.json();
return data.variant;
}
export default async function HomePage() {
const cookieStore = cookies();
const userId = cookieStore.get('user_id')?.value || 'anonymous';
const variant = await getFeatureFlag(userId, 'hero-layout');
return (
<main>
{variant === 'simple' ? <SimpleHero /> : <ComplexHero />}
</main>
);
}
Hybrid Approach
Many modern platforms use a hybrid: the server assigns a variant and passes it to the client via a script tag or cookie. The client then applies the changes.
Popular A/B Testing and Feature Flag Tools
1. LaunchDarkly
Type: Feature flag management platform (SaaS)
Strengths:
- Enterprise-grade (SOC 2 compliant)
- Real-time flag updates (no deployment needed)
- Advanced targeting (by user attributes, location, device)
- Integrations with Datadog, Slack, JIRA
Best For: Startups to enterprises that want a managed solution with robust support.
Pricing: Starts at $10/user/month; has a free tier for small projects.
Example:
import * as LaunchDarkly from 'launchdarkly-js-client-sdk';
const client = LaunchDarkly.initialize('YOUR_CLIENT_SIDE_ID', {
key: 'user-123',
email: 'user@example.com',
});
client.on('ready', () => {
const showNewDashboard = client.variation('new-dashboard', false);
if (showNewDashboard) {
renderNewDashboard();
} else {
renderOldDashboard();
}
});
2. Optimizely
Type: Experimentation platform
Strengths:
- A/B testing + feature flags + personalization
- Visual editor for non-technical users
- Statistical engine for experiment analysis
- Integrations with Google Analytics, Segment
Best For: Marketing-driven teams, e-commerce, enterprises.
Pricing: Custom (starts at ~$50k/year for Full Stack).
3. GrowthBook
Type: Open-source experimentation platform
Strengths:
- Self-hosted or cloud-hosted
- Bayesian statistics engine
- Native integrations with analytics tools (Mixpanel, Amplitude)
- Built for data teams
Best For: Engineering-led startups, data-driven organizations.
Pricing: Free (open-source); cloud hosting starts at $20/month.
Example:
import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'YOUR_CLIENT_KEY',
enableDevMode: true,
attributes: {
id: 'user-123',
country: 'US',
},
});
await gb.loadFeatures();
if (gb.isOn('new-checkout')) {
renderNewCheckout();
} else {
renderOldCheckout();
}
4. Unleash
Type: Open-source feature flag management
Strengths:
- Self-hosted or cloud
- Strategy-based rollouts (gradual, user-based, A/B)
- SDKs for 15+ languages
- Privacy-first (GDPR-compliant)
Best For: DevOps teams, enterprises with compliance requirements.
Pricing: Free (open-source); cloud starts at $80/month.
5. PostHog
Type: Open-source product analytics + feature flags
Strengths:
- All-in-one: analytics, session replay, feature flags, experiments
- Self-hosted or cloud
- No third-party tracking (privacy-focused)
- Ideal for startups
Best For: Early-stage startups, privacy-conscious teams.
Pricing: Free tier; paid starts at $0.0001/event.
Implementing a Simple A/B Test from Scratch
If you're not ready to adopt a third-party tool, here's a DIY approach.
Step 1: Assign Users to Variants
Use a hash function to consistently assign users to the same variant:
function hashCode(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = (hash << 5) - hash + str.charCodeAt(i);
hash |= 0; // Convert to 32-bit integer
}
return Math.abs(hash);
}
function getVariant(userId, experimentName) {
const hash = hashCode(userId + experimentName);
return hash % 2 === 0 ? 'control' : 'variant';
}
const userId = 'user-12345';
const variant = getVariant(userId, 'checkout-button-color');
console.log(variant); // 'control' or 'variant'
Step 2: Track Events
Log which variant the user saw and their actions:
function trackEvent(userId, experimentName, variant, eventType) {
fetch('/api/analytics', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userId, experimentName, variant, eventType, timestamp: Date.now() }),
});
}
// User saw the variant
trackEvent(userId, 'checkout-button-color', variant, 'view');
// User clicked the button
document.querySelector('#cta-button').addEventListener('click', () => {
trackEvent(userId, 'checkout-button-color', variant, 'click');
});
Step 3: Analyze Results
Query your analytics database to calculate conversion rates:
SELECT
variant,
COUNT(DISTINCT user_id) AS total_users,
SUM(CASE WHEN event_type = 'click' THEN 1 ELSE 0 END) AS conversions,
(SUM(CASE WHEN event_type = 'click' THEN 1 ELSE 0 END) * 1.0 / COUNT(DISTINCT user_id)) AS conversion_rate
FROM events
WHERE experiment_name = 'checkout-button-color'
GROUP BY variant;
| variant | total_users | conversions | conversion_rate |
|---|---|---|---|
| control | 5000 | 500 | 0.10 |
| variant | 5000 | 600 | 0.12 |
The variant has a 2% higher conversion rate. But is it statistically significant?
Understanding Statistical Significance
Not every difference is meaningful. You need to run your experiment long enough and with enough users to be confident the result is not due to random chance.
Key Concepts
- Sample Size: The number of users in each group. Larger samples = more reliable results.
- P-Value: The probability that the observed difference occurred by chance. A p-value < 0.05 is considered statistically significant.
- Confidence Interval: The range within which the true effect likely lies (e.g., "We are 95% confident the true conversion rate increase is between 1.5% and 2.5%").
Tools for Calculation
Use an online calculator (e.g., Evan Miller's A/B Test Calculator) or a library:
import { chiSquaredTest } from 'simple-statistics';
const controlConversions = 500,
controlTotal = 5000;
const variantConversions = 600,
variantTotal = 5000;
const pValue = chiSquaredTest([
[controlConversions, controlTotal - controlConversions],
[variantConversions, variantTotal - variantConversions],
]);
console.log(pValue < 0.05 ? 'Significant!' : 'Not significant');
Ethical and UX Considerations
A/B testing is powerful, but it comes with responsibility.
Best Practices
- Informed Consent: Users should know their data is being used to improve the product. Include this in your privacy policy.
- Avoid Dark Patterns: Don't test deceptive practices (e.g., hiding the unsubscribe button).
- Consistency: Ensure a user always sees the same variant. Random switching creates a confusing experience.
- Minimize Risk: Test on a small percentage of users first (canary release).
- Accessibility: Ensure all variants are accessible. Don't sacrifice usability for conversion rate.
Conclusion
A/B testing and feature flags are not just tools�they are a mindset. By treating every product decision as a hypothesis to be tested, you move from guesswork to evidence-based development. Whether you use a sophisticated platform like LaunchDarkly or build your own experimentation framework, the key is to:
- Formulate a clear hypothesis
- Define success metrics
- Run the experiment
- Analyze the data
- Act on the insights
Start small. Test a button color, a headline, or a layout. Measure the impact. Share the results with your team. Over time, this culture of experimentation will become your competitive advantage.
Ready to build data-driven products? Sign up for ScanlyApp and integrate continuous testing and experimentation into your workflow.