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:

  1. The first tag hides the page before the browser paints it, and makes early avsb.* calls safe.
  2. The second tag downloads the bundle in the background, without blocking anything.
  3. 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.
  4. 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.

Was this helpful?