# Segment

URL: https://docs.ablyft.com/developers/integrations/segment/

> Send the experiment and variation a visitor saw to Segment as a track event.



ABlyft has a built-in Segment integration. Once you switch it on, ABlyft sends an `ABlyft Experiment Viewed` event to
Segment each time a visitor sees an experiment. From Segment the event reaches the Debugger, your warehouse and every
connected destination.

## What you need

* The Segment analytics.js library is already loaded on the pages where your experiments run.

## Activate the integration

1. Open **Project → Integrations**.
2. On the **Segment** card, switch the toggle from **Not active** to **Activated** and confirm.

ABlyft then republishes the project. There are no further settings.

## Where you see the data in Segment

Trigger: **Experiment viewed**. ABlyft sends the data every time the experiment runs for the visitor. If the tool loads slightly later, ABlyft tries again for a short time.

* Event `ABlyft Experiment Viewed`
* Properties `experiment_id`, `experiment_name`, `variation_id`, `variation_name`: IDs and names of the experiment and the variation

Need a different format? [Build a custom integration](https://docs.ablyft.com/developers/integrations/custom-integrations/).

* **Debugger:** In your source, open **Sources → Debugger**. The event `ABlyft Experiment Viewed` shows up with the four
  properties under **Pretty** and **Raw**.
* **Warehouse:** Segment stores track events in an event table named after the event, with one column per property.
* **Destinations:** Every destination that receives track events from this source gets the event. Filter or break down
  by `experiment_name` and `variation_name` there.

## Check the setup

1. Open the Segment Debugger of your source.
2. Open a page with a running experiment, in a variation you are bucketed into.
3. Look for `ABlyft Experiment Viewed` and check the four properties.

## Notes

> **Consent and tracking:** The integration does not run when tracking is disabled for the visitor (opt-out or Do Not Track). Segment may need
> its own consent category in your consent tool. Destinations can drop events when the visitor has not consented to
> them.

[Segment documentation](https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/website/javascript/)

