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

1

Go to Project Settings > Integrations

Open your project, click Settings, then open the Integrations tab.

2

Turn on Segment

Find the Segment card and switch it on.

3

Choose anything else you want sent

Under Also send, tick conversions, purchases, or recommendation events. Experiment views are always sent.

4

Save

Click Save. Your changes reach your live site within about a minute.

The Segment card, switched on. Experiment views use Segment's own Experiment Viewed event automatically.
  1. The on/off switch, top right of the card.
  2. The Also send checklist for conversions, purchases, and recommendation events.

What is sent

When a visitor is shown a variation:

JavaScript
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});
JavaScript8 lines

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.

EventDefault nameExtra properties
Experiment viewExperiment ViewednonInteraction: 1
Conversionavsb_goalgoal_key, plus revenue or value when you sent one
Purchaseavsb_purchaserevenue, currency, transaction_id
Recommendation seenavsb_rec_impressionthe recommendation details, such as recipe and items
Recommendation clickedavsb_rec_clickthe 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.
User identity

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.

Segment has to be there already

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.

Was this helpful?