Snippet Installation
The A vs B snippet is a small JavaScript file that powers everything: choosing
which visitor sees which variation, applying the change, and tracking what
happens next. Installing it is two tags in your <head>, and this section shows
you how to add them to any kind of site.
How the snippet works
When a visitor loads your site:
- The first tag hides the page before the browser paints it, and makes early
avsb.*calls safe. - The second tag downloads the bundle in the background, without blocking anything.
- The bundle fetches your project's experiment config from the A vs B CDN, works out which experiments the visitor qualifies for, assigns them to a variation, and applies that variation's changes.
- The page is revealed, already in the right state, so the visitor never sees the original content change in front of them.
It then listens for events (clicks, pageviews, custom events) and sends that data back to A vs B so results show up in your dashboard.
Pick your install guide
Start with Quick Install if you can edit your site's HTML. Otherwise jump to the guide for your platform.
Quick InstallThe fastest way to add the snippet: two tags in the head of your site.
Popular PlatformsStep-by-step for WordPress, Shopify, Webflow, Squarespace, and Wix.
Google Tag ManagerDeploy the snippet through GTM without touching your site's code.
Single Page AppsReact, Next.js, Vue, Angular: how the snippet handles client-side navigation.
Verifying InstallationConfirm the snippet is live and fix common installation problems.
Anti-FlickerHow A vs B stops the original page flashing before a variation loads.
Consent Mode (GDPR)Hold the snippet until a visitor consents, or run experiments while measurement follows their consent categories. Works with OneTrust, Cookiebot, and custom banners.