# Send Feature Experimentation Event to Segment

{% hint style="info" %}
**FE\&R Visitor ID & Segment.io User ID**

For the user matching to be achieved, and let FE\&R target your Segment traits, the User ID sent in the Segment .identify calls must be the same value than the FE\&R Visitor ID sent to the decision API.

Segment documentation on User ID [here](https://segment.com/docs/connections/spec/identify/#user-id).
{% endhint %}

This guide explains how to configure **AB Tasty server-side events** to be forwarded to **Segment (SegmentIO)**.

{% stepper %}
{% step %}

### Configure Segment

#### Retrieve the Segment API Key

1. Log into your **Segment Dashboard**
2. Select the relevant **Source**
3. Navigate to:

```
Settings → API Keys
```

4. [Copy the **Write Key**](#user-content-fn-1)[^1]

You will use this key when configuring the connector in AB Tasty.
{% endstep %}

{% step %}

### Create the Segment Connector in AB Tasty

1. Go to the **Integration Hub** in AB Tasty
2. Create a new [**SegmentIO Connector (PUSH)**](#user-content-fn-2)[^2]
3. Paste the **Segment Write Key**
4. Save the connector

Once created, AB Tasty will be able to forward **server-side events to Segment**.
{% endstep %}

{% step %}

### Visitor ID Requirement

For AB Tasty to send events to Segment, **the visitor ID must be known by Segment**.

This means the visitor must first be **identified or tracked by Segment** before AB Tasty sends events.

### Identify the Visitor in Segment

Example:

```javascript
analytics.identify('YOUR_VISITOR_ID', {
  email: "user@example.com",
  name: "John Doe"
});
```

This ensures Segment associates events with the correct user.
{% endstep %}
{% endstepper %}

### Retrieve the Visitor ID from Segment

If Segment is already running on the website, you can retrieve the visitor identifier.

#### Anonymous ID

```javascript
window.analytics.user().anonymousId();
```

#### User ID (if identified)

```javascript
window.analytics.user().userId();
```

### Send the Visitor ID to AB Tasty

The **same visitor ID used in Segment must be used when calling the AB Tasty Decision API**.

Example:

```
visitorId = window.analytics.user().anonymousId()
```

Then pass it to the **Decision API** request.

If the visitor ID used by AB Tasty **does not match the one known by Segment**, the event **will not be forwarded to Segment**.

### Event Flow Overview

```
User → Segment identifies visitor
      ↓
Visitor ID retrieved from Segment
      ↓
Decision API called with same visitor ID
      ↓
AB Tasty generates server-side event
      ↓
Event sent to Segment via connector
```

[^1]: <img src="https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FU2JAokhCGBPaOHW0CRgg%2FCapture%20d%E2%80%99e%CC%81cran%202026-03-10%20a%CC%80%2017.12.05.png?alt=media&#x26;token=32db4ba5-97cf-4469-b60b-56eb85a53730" alt="" data-size="original">

[^2]: <img src="https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FJVaUsWa06oG94w9JS8nn%2FCapture%20d%E2%80%99e%CC%81cran%202026-03-10%20a%CC%80%2017.11.23.png?alt=media&#x26;token=72275ee4-797c-4dee-9059-8d7ef6cff26f" alt="" data-size="original">
