> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifygtm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Segment integration guide

> Send Segment events into Unify.

## Overview

If you use Segment to collect website analytics, Unify can be connected to your
Segment workspace as a destination to reveal web traffic data. This will also
let you build audiences and Plays using Segment analytics data.

## Steps

<Note>
  If you’re also using the Unify Tag, ensure it isn’t running on the same
  pages as Segment. Otherwise, events may be double counted.
</Note>

### Generate a key in Unify

1. Log in to Unify

2. Navigate to [Settings → Integrations → Segment](https://app.unifygtm.com/dashboard/settings/integrations/segment) and click **Setup**

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/53.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=f629a09a07d5de67bc7cbfa456108893" alt="Setup.png" width="2000" height="1329" data-path="images/53.png" />
   </Frame>

3. Click the **Copy** button to copy the write key to your clipboard

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/54.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=b6ebe5630f7cd5731f7ffa0c68fcc759" alt="Write Key.png" width="2000" height="1329" data-path="images/54.png" />
   </Frame>

### Add Segment destination

1. Log in to Segment and click on the **Destinations** tab in the sidebar

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/55.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=24da26163177fb33eb7f27f3048593c5" alt="Screenshot 2023-08-23 at 8.02.29 PM.png" width="480" height="552" data-path="images/55.png" />
   </Frame>

2. Click **Add destination** in the top right corner

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/56.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=379089fb5a0816300977290b6eecabc1" alt="Screenshot 2023-08-23 at 7.02.47 PM.png" width="580" height="182" data-path="images/56.png" />
   </Frame>

3. Search for “webhook” and select the **Webhook (actions)** destination

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/57.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=f8ba7a4e1baf18efd52cbf086b547005" alt="Screenshot 2023-08-23 at 7.03.49 PM.png" width="580" height="249" data-path="images/57.png" />
   </Frame>

4. Click **Add destination** again in the top right corner

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/58.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=0fce45f6e023787737ffed8968e51334" alt="Screenshot 2023-08-23 at 7.05.58 PM.png" width="2000" height="1312" data-path="images/58.png" />
   </Frame>

5. Select website source whose data you want to send to Unify and then click **Next**

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/59.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=badeaf966f78d2bb57e6452001d0a48d" alt="Screenshot 2023-08-23 at 7.08.02 PM.png" width="2000" height="1120" data-path="images/59.png" />
   </Frame>

6. Give this destination a name, make sure **Fill in settings manually** is selected, and click **Create destination**

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/60.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=1f16e50997242eb3c75af440f8b96feb" alt="Screenshot 2023-08-23 at 7.13.50 PM.png" width="2000" height="1120" data-path="images/60.png" />
   </Frame>

7. Click on the **Mappings** tab on the top and then select **New Mapping**

   <Frame>
     <img src="https://mintcdn.com/unify-19/4OhjWaiyXHWcw8Ko/images/61.png?fit=max&auto=format&n=4OhjWaiyXHWcw8Ko&q=85&s=34ea46b0bb84ce018cf2bd321eaa3288" alt="Screenshot 2023-08-23 at 7.18.04 PM.png" width="2000" height="1310" data-path="images/61.png" />
   </Frame>

8. Choose the **Send** option

   <Frame>
     <img src="https://mintcdn.com/unify-19/tLDiSeX7xLri6Dbl/images/segment/send-option.png?fit=max&auto=format&n=tLDiSeX7xLri6Dbl&q=85&s=7ee58a8f7de15b1311befa69eedca88d" alt="send-option.png" width="2554" height="1246" data-path="images/segment/send-option.png" />
   </Frame>

9. Fill in the following mapping values…
   1. Under **Section 2**:

      1. Unify currently supports Page, Track, and Identify event types. You should select **Add Condition** for each event type
         and select **any**.
      2. If there are specific event types that you know you do not want to forward to Unify, you can omit them.

      <Frame>
        <img src="https://mintcdn.com/unify-19/tLDiSeX7xLri6Dbl/images/segment/event-trigger.png?fit=max&auto=format&n=tLDiSeX7xLri6Dbl&q=85&s=9759cecde7671939895f1e02bd115031" alt="event-trigger.png" width="1982" height="622" data-path="images/segment/event-trigger.png" />
      </Frame>

      3. Click **Generate sample event** to populate the box with an example Segment event

      <Frame>
        <img src="https://mintcdn.com/unify-19/tLDiSeX7xLri6Dbl/images/segment/generate-sample-event.png?fit=max&auto=format&n=tLDiSeX7xLri6Dbl&q=85&s=f7391206c50cea548fb50be0f1fa1e6c" alt="generate-sample-event.png" width="1616" height="686" data-path="images/segment/generate-sample-event.png" />
      </Frame>

   2. Under **Section 4**:

      1. Next to **URL**, fill in the following value:

         ```
         https://analytics.unifygtm.com/api/v1/webhooks/segment
         ```

      2. List two values under **Headers** (click **Add Mapping Field** to add more boxes):
         1. `<YOUR WRITE KEY` → `X-Write-Key`
         2. `application-json` → `Content-Type`

      3. Be sure to replace `<YOUR WRITE KEY>` with the key you copied earlier

      <Frame>
        <img src="https://mintcdn.com/unify-19/tLDiSeX7xLri6Dbl/images/segment/map-fields.png?fit=max&auto=format&n=tLDiSeX7xLri6Dbl&q=85&s=a89aebdf9d3354839da236b7ce5934fe" alt="map-fields.png" width="1918" height="1638" data-path="images/segment/map-fields.png" />
      </Frame>

   3. Under **Section 5**:

      1. Send a test event to verify that it’s working

      <Frame>
        <img src="https://mintcdn.com/unify-19/hCdysogYM6qFbUs-/images/66.png?fit=max&auto=format&n=hCdysogYM6qFbUs-&q=85&s=c089096e1eec784eaa551bdbdf25295d" alt="Screenshot 2023-08-23 at 7.44.09 PM.png" width="2000" height="1031" data-path="images/66.png" />
      </Frame>

That’s it! If you see **Test event successfully received by destination.**, you’re all set. Traffic should now be flowing into Unify.
