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
Go to Project Settings > Integrations
Enable Segment
Enter your Write Key (optional)
window.analytics (the Segment analytics.js object) already initialized on your page.Save
What is sent through Segment
When a visitor is enrolled in a variation, A vs B calls:
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.
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.window.analytics object that your existing Segment snippet has already set up.