A/B Testing Setup on Website (Google Optimize/VWO/Optimizely)

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
A/B Testing Setup on Website (Google Optimize/VWO/Optimizely)
Medium
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

A/B Testing Setup

Google Optimize shut down in 2023. Current tools include Statsig, Growthbook, Optimizely, VWO, or custom implementation via Edge Functions.

Tool Selection

Tool Type Best For
Growthbook Open source / SaaS Technical teams, self-hosted
Statsig SaaS Quick start, analytics integration
Optimizely Enterprise SaaS Large companies, complex experiments
VWO SaaS Marketing teams without dev resources
Vercel Edge Experiments PaaS Next.js on Vercel
Custom implementation - Full control, minimal overhead

Implementation via Vercel Edge Middleware

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

const EXPERIMENT_COOKIE = 'exp_checkout_v2';
const VARIANTS = ['control', 'variant-a', 'variant-b'];

function assignVariant(): string {
  const rand = Math.random();
  if (rand < 0.34) return 'control';
  if (rand < 0.67) return 'variant-a';
  return 'variant-b';
}

export function middleware(request: NextRequest) {
  const response = NextResponse.next();

  // Exclude: bots, already-assigned users
  const existing = request.cookies.get(EXPERIMENT_COOKIE)?.value;
  if (existing && VARIANTS.includes(existing)) {
    return response;
  }

  const variant = assignVariant();
  response.cookies.set(EXPERIMENT_COOKIE, variant, {
    maxAge: 60 * 60 * 24 * 30, // 30 days
    httpOnly: true,
    sameSite: 'lax',
  });

  // Pass variant in header for Server Components
  response.headers.set('x-ab-checkout', variant);
  return response;
}

export const config = {
  matcher: ['/checkout/:path*'],
};
// app/checkout/page.tsx
import { cookies, headers } from 'next/headers';

export default function CheckoutPage() {
  const variant = headers().get('x-ab-checkout') ??
                  cookies().get('exp_checkout_v2')?.value ??
                  'control';

  return (
    <>
      {variant === 'control' && <CheckoutV1 />}
      {variant === 'variant-a' && <CheckoutV2OneStep />}
      {variant === 'variant-b' && <CheckoutV2TwoStep />}
      <ABTracker experiment="checkout_v2" variant={variant} />
    </>
  );
}

Results Tracking

// components/ABTracker.tsx (Client Component)
'use client';

import { useEffect } from 'react';

export function ABTracker({ experiment, variant }: {
  experiment: string;
  variant: string;
}) {
  useEffect(() => {
    // GA4
    gtag('event', 'experiment_impression', {
      experiment_id: experiment,
      variant_id: variant,
    });

    // PostHog
    posthog.capture('$experiment_started', {
      '$experiment_id': experiment,
      '$variant_key': variant,
    });
  }, [experiment, variant]);

  return null;
}

// Conversion tracking — at purchase time
function trackConversion(variant: string) {
  gtag('event', 'purchase', {
    experiment_id: 'checkout_v2',
    variant_id: variant,
    value: orderTotal,
  });
}

Statsig: Quick Integration

// Statsig SDK
import Statsig from 'statsig-node';

await Statsig.initialize(process.env.STATSIG_SERVER_KEY!);

// In API route / Server Action
const experiment = Statsig.getExperiment(
  { userID: userId, email: userEmail },
  'checkout_redesign'
);

const checkoutLayout = experiment.get('layout', 'single-page');
const ctaColor = experiment.get('cta_color', 'blue');
// Client side (React SDK)
import { useExperiment } from 'statsig-react';

function PricingCTA() {
  const { config } = useExperiment('pricing_cta');
  const buttonText = config.get('button_text', 'Get Started');
  const buttonVariant = config.get('button_variant', 'primary');

  return (
    <Button
      variant={buttonVariant}
      onClick={() => {
        statsig.logEvent('cta_clicked', buttonText);
      }}
    >
      {buttonText}
    </Button>
  );
}

Statistical Significance

Before running a test, calculate the required sample size:

# Python: sample size calculation
from statsmodels.stats.power import zt_ind_solve_power

# CVR = 3%, expected effect = +15% (to 3.45%)
baseline_rate = 0.03
expected_effect = 0.15  # relative improvement
lift = baseline_rate * expected_effect  # 0.0045 absolute

n = zt_ind_solve_power(
    effect_size=lift / (baseline_rate * (1 - baseline_rate)) ** 0.5,
    alpha=0.05,  # 95% confidence
    power=0.8,   # 80% statistical power
)
print(f"Sample size per variant: {int(n)}")  # ~12,000

Rule: do not stop the test before reaching the planned sample size, even if results look promising.

Result Analysis in GA4

GA4 → Explore → Free Form
Dimension: Experiment Variant (custom event parameter)
Metric: Conversions, Revenue
Segment by variant → compare conversions

A/B testing setup with GA4/PostHog tracking — 2–4 business days depending on the tech stack.