Segment Integration
A vs B sends your experiment data through the Segment library that is already running on your page. There is no write key to paste in: if window.analytics is there, we talk to it.
Because Segment routes data onward, connecting it once means your experiment data reaches every destination you have set up: your warehouse, your CRM, your email platform, and anything else.
Experiment views use Segment's own A/B testing event, Experiment Viewed, so destinations that already understand that event need no extra mapping.
Setup
Go to Project Settings > Integrations
Open your project, click Settings, then open the Integrations tab.
Turn on Segment
Find the Segment card and switch it on.
Choose anything else you want sent
Under Also send, tick conversions, purchases, or recommendation events. Experiment views are always sent.
Save
Click Save. Your changes reach your live site within about a minute.
- The on/off switch, top right of the card.
- The Also send checklist for conversions, purchases, and recommendation events.
What is sent
When a visitor is shown a variation:
analytics.track('Experiment Viewed', { experiment_id: '482', experiment_name: 'Homepage hero', variation_id: '1913', variation_name: 'Variant B', event_id: '3f9a2b1c-7d4e-4a58-9c02-5e6d1f8b3a47', nonInteraction: 1});nonInteraction marks the view as something the visitor did not do, so it does not skew engagement metrics in your destinations. Conversions and purchases are real interactions, so they never carry it.
| Event | Default name | Extra properties |
|---|---|---|
| Experiment view | Experiment Viewed | nonInteraction: 1 |
| 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.
Renaming events
Every name in the table can be changed on the card. Leave a box empty to keep the standard name shown inside it. Renaming Experiment Viewed means destinations that expect Segment's standard A/B event will stop recognising it, so change it only if you have a reason to.
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. Segment's Debugger shows it live.
If nothing shows up in Segment's Debugger, check Segment first. Open your browser console and type window.analytics. If that returns nothing, Segment is not loaded on the page, and nothing on our side can fix that.
Using experiment data downstream
- Warehouse analysis: join experiment views with conversion events in SQL to build your own analysis.
- Audiences: build a Segment audience from everyone shown a specific variation and use it in your ad platforms.
- Email: trigger different sequences based on which variation somebody saw.
Segment attaches these events to the same profile it uses for everything else, whether that is an anonymous ID or a user ID after an identify() call.
A vs B never loads Segment for you. This integration uses the window.analytics object your own Segment snippet sets up, so it does nothing on pages where Segment is not installed.