/Docs

Segment Integration

The Segment integration forwards A vs B experiment events through your Segment workspace using analytics.track(). Because Segment acts as a data router, connecting A vs B to Segment means your experiment data automatically flows to every downstream destination you have configured — your data warehouse, your email platform, your CRM, and any other tool connected to Segment.

Setup

1

Go to Project Settings > Integrations

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

Enable Segment

Find the Segment card and toggle it on.
3

Enter your Write Key (optional)

Enter your Segment Source Write Key. You can find this in Segment under Sources > [Your Source] > Settings > API Keys. If you leave the Write Key blank, the snippet will auto-detect an existing window.analytics (the Segment analytics.js object) already initialized on your page.
4

Save

Click Save. A vs B will now forward events through Segment on each experiment enrollment.

What is sent through Segment

When a visitor is enrolled in a variation, A vs B calls:

javascript
1analytics.track('avsb_experiment', {
2 experiment_id: 'exp_abc123',
3 experiment_name: 'Homepage Hero Test',
4 variation_id: 'var_xyz789',
5 variation_name: 'Variation B',
6 event_name: 'experiment_viewed'
7});

This event flows through your Segment pipeline to all connected destinations. If your data warehouse receives Segment events, experiment enrollment data will be available there for SQL analysis. If your email platform receives Segment events, you can trigger emails based on experiment enrollment.

Using experiment data in downstream tools

Once experiment events are flowing through Segment, you can use the experiment_name and variation_name properties to:

  • Warehouse analysis — join experiment enrollment events with conversion events in your data warehouse to build custom A/B analysis outside of A vs B.
  • Audience creation— build Segment audiences based on experiment enrollment (e.g., "users who saw Variation B of the pricing test") and use those audiences in your ad platforms.
  • Email personalization — trigger different email sequences based on which variation a user was assigned to.
User identity
Segment associates events with user profiles using the anonymous ID (for logged-out visitors) or the user ID (after an identify() call). A vs B experiment events will be attached to the same profile that Segment uses for all your other events, making it easy to trace a visitor's full journey including their experiment enrollment.
Tip
If you are already using Segment on your site, enabling the integration with auto-detection (leaving the Write Key blank) is the fastest path. The snippet will use the window.analytics object that your existing Segment snippet has already set up.