Setting Up Google Optimize for A/B Testing
Important: Google Optimize discontinued on September 30, 2023. Existing integrations stopped working. If your site used Optimize — migration to an alternative tool is required.
Google Optimize Replacements
| Tool | Type | Features |
|---|---|---|
| VWO | Paid | Closest functional replacement |
| Optimizely | Paid | Enterprise-level |
| AB Tasty | Paid | Good GA4 integration |
| Statsig | Paid/Free | Feature flags + experiments |
| GrowthBook | Open-source | Self-hosted, free |
| Eppo | Paid | Data Warehouse native |
GrowthBook: Open-Source Alternative
# Docker installation
docker-compose up -d # from official docker-compose.yml
# Dashboard: http://localhost:3000
// SDK integration
import { GrowthBook } from '@growthbook/growthbook'
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'sdk-abc123',
enableDevMode: true,
trackingCallback: (experiment, result) => {
gtag('event', 'experiment_viewed', {
experiment_id: experiment.key,
variant_id: result.variationId,
})
}
})
await gb.loadFeatures()
// Use in component
const ctaText = gb.getFeatureValue('cta_text', 'Buy now')
const showBanner = gb.isOn('promo_banner')
What Was in Google Optimize and How to Replace
A/B test via visual editor: Optimize allowed creating tests with clicks, no code. GrowthBook requires minimal code, VWO provides a visual editor.
Audience targeting: Optimize integrated with GA4 audiences. VWO and AB Tasty have their own segments + GA4 integration.
Personalization: Optimize 360 (paid) supported personalization. Replacements: AB Tasty, Dynamic Yield, Monetate.
Migrating Existing Tests
// Was (Google Optimize)
gtag('event', 'optimize.callback', {
name: 'ABCxxx',
callback: (value, name) => {
console.log('Experiment:', name, 'Variant:', value)
}
})
// Now (GrowthBook)
const variant = gb.getFeatureValue('experiment_name', 'control')
// Then apply variant manually
Custom A/B Without Paid Tools
For simple tests without visual editor — self-hosted GA4 solution:
// feature-flags.js
const EXPERIMENTS = {
'hero_headline': {
variants: ['control', 'variant_a'],
weights: [0.5, 0.5]
}
}
function assignVariant(experimentId) {
const stored = sessionStorage.getItem(`exp_${experimentId}`)
if (stored) return stored
const exp = EXPERIMENTS[experimentId]
const random = Math.random()
let cumulative = 0
let chosen = exp.variants[0]
for (let i = 0; i < exp.variants.length; i++) {
cumulative += exp.weights[i]
if (random < cumulative) {
chosen = exp.variants[i]
break
}
}
sessionStorage.setItem(`exp_${experimentId}`, chosen)
gtag('event', 'experiment_viewed', { experiment_id: experimentId, variant_id: chosen })
return chosen
}
Delivery Time
Migration from Google Optimize to GrowthBook or VWO + transferring existing tests — 2–3 business days.







