Google Analytics Integration
A vs B sends your experiment data to Google Analytics 4 through the Google tag that is already running on your page. There is nothing to paste in and no measurement ID to find: if gtag is on the page, we talk to it.
A variant is one specific version being tested: the control, or one of the challengers. Experiment views use Google's own A/B testing event shape, so GA4's built-in experiment dimension picks them up with no setup at all.
Setup
Go to Project Settings > Integrations
Open your project in A vs B, click Settings in the left sidebar, then open the Integrations tab.
Turn on Google Analytics 4
Find the Google Analytics 4 card and switch it on. Experiment views start sending as soon as you save.
Choose anything else you want sent
Under Also send, tick conversions, purchases, or recommendation events. Experiment views are always sent; everything else is your choice.
Save
Click Save. Your changes reach your live site within about a minute.
- The on/off switch, top right of the card.
- Send to measurement ID, for routing to one specific Google tag. Leave it blank to send to every Google tag on the page.
- The Also send checklist for conversions, purchases, and recommendation events.
What is sent
When a visitor is shown a variation:
gtag('event', 'experience_impression', { exp_variant_string: 'AVSB-482-1913', avsb_experiment_name: 'Homepage hero', avsb_variation_name: 'Variant B', avsb_event_id: '3f9a2b1c-7d4e-4a58-9c02-5e6d1f8b3a47'});exp_variant_string is the field GA4 reads for its built in experiment dimension. The numbers in it are the experiment and variation IDs shown in A vs B.
Everything else you switch on is sent with the fuller set of fields:
gtag('event', 'avsb_purchase', { avsb_experiment_id: '482', avsb_experiment_name: 'Homepage hero', avsb_variation_id: '1913', avsb_variation_name: 'Variant B', avsb_event_id: 'd41c8f2e-6b90-4a17-8f3c-2ac5b9e0d714', revenue: 49.99, currency: 'USD', transaction_id: 'ORDER-8842'});| Event | Default name | Extra fields |
|---|---|---|
| Experiment view | experience_impression | none |
| Conversion | avsb_goal | goal_key, plus revenue or value when you sent one |
| Purchase | avsb_purchase | revenue, currency, transaction_id |
| Recommendation seen | avsb_rec_impression | the recommendation details, such as recipe and items |
| Recommendation clicked | avsb_rec_click | the recommendation details, such as recipe, item, and position |
Empty fields are left out rather than sent as blanks, so you never get a revenue: null row in GA4.
Sending to one specific property
If your page runs more than one Google tag, you can send A vs B events to just one of them. Put that measurement ID in Send to measurement ID on the card. Leave it blank to send to every Google tag on the page.
Renaming events
Every name in the table above can be changed on the card. Leave a box empty to keep the standard name shown inside it.
Google Analytics rejects some names outright, so A vs B refuses them when you save. A name has to start with a letter and use only letters, numbers, and underscores, and it cannot start with ga_, google_, firebase_, or gtag. Names Google reserves for its own events are refused too, such as session_start, first_visit, and screen_view. purchase is refused as well, because reusing it would double count your own ecommerce. If a name is turned down, the reason appears under that box on the card, and you can pick a slightly different one, for example avsb_session_start.
Check it works
On the Integrations tab, use Send a test event. It opens your site in a new tab and sends one clearly labelled test event, avsb_test_event, to every tool you have switched on. Open GA4's DebugView or Realtime report to watch it arrive.
Your project needs at least one live experiment for this to work, since the test event is sent against the first one.
Viewing in GA4 reports
GA4 takes up to 24 hours to process new data into standard reports, though DebugView and Realtime are immediate.
- In GA4, go to Explore and create a new Free Form exploration.
- Add Event count as a metric.
- Add GA4's built-in experiment variant dimension. It fills itself from
exp_variant_stringwith no setup. - Filter by Event name =
experience_impressionto see only experiment views.
You can also break any existing report down by avsb_experiment_name and avsb_variation_name once you have registered them.
The avsb_ fields are custom event parameters. They show up in Explore straight away. For standard reports, register them once under Admin > Custom definitions as event scoped custom dimensions.
Your GA4 numbers and your A vs B results will be close but not identical. Ad blockers, consent choices, and browser privacy settings affect the two systems differently. Every event carries avsb_event_id, a unique ID you can use to line individual events up if you export GA4 data to BigQuery.