Setup experiments
Run A/B tests without another deploy. Build variants in the visual editor, preview them on your live site, and ship the winner with one click.
How experiments work
Every experiment has a control and up to three test variants. When a visitor loads your page, the analytics script:
- Fetches active experiments for the URL.
- Deterministically buckets the visitor into a variant using a DJB2 hash of
visitorId + experimentId, so the same visitor always sees the same variant. - Applies DOM changes before paint, so there's no flicker.
- Fires an
experiment_impressionevent and tags every subsequent event with the variant.
Create an experiment
Open the Experiments tab
In the dashboard sidebar, click Experiments, then New Experiment. A two-step dialog walks you through setup.
New ExperimentStep 1 of 2Experiment nameHero headline testPrimary metricCustom event▾Event namesignup▾Hypothesis (optional)Changing the headline will lift signups ~15%.CancelNextPick a primary metric
Your metric is how you'll judge the winner. Options:
custom_event: any conversion or custom event you've fired.session_duration: average engagement time per session.bounce_rate: % of sessions with only one pageview.
Set URL targeting
Once the experiment is created, variant rules let you choose how the target URL matches:
exact,contains,starts_with, orallpages.
Define variants
A variant is a list of DOM changes. Each change has a CSS selector, a change type, and a value.
| Type | What it does |
|---|---|
| text | Replaces textContent of the matched element. |
| html | Replaces innerHTML; use for rich formatting. |
| style | Sets an inline style property (e.g. backgroundColor). |
| class | Sets className; useful for theme flips. |
| css | Injects a <style> block applying property to selector. |
Under the hood, each variant stores its changes as JSON:
[
{
"selector": "#hero-title",
"changeType": "text",
"value": "Ship experiments in seconds"
},
{
"selector": "#cta-button",
"changeType": "style",
"property": "backgroundColor",
"value": "oklch(0.62 0.22 352)"
}
]Use the visual editor
Click Open visual editor on any variant to pop a new tab with your live site plus an overlay toolbar. Click any element to edit its text, styles, or classes. No selectors to write by hand.
Click any element to select it. The pink highlight follows your cursor.
?gmp_edit=1 in the URL. No install step needed.Preview before launch
Each variant has a sharable preview URL that embeds the changes as a base64 param, so teammates can review without affecting real users:
https://yourdomain.com/?gmp_preview=<BASE64_CHANGES>?gmp_preview is present, so QA sessions won't pollute your results.Read results
The results panel shows conversion rate per variant, expected lift vs. control, and the probability each variant beats control. Most teams ship when that probability crosses 95% with a minimum sample of a few hundred visitors per variant.
<head>. That gives the script a chance to apply variants before paint, preventing a flash of the control.