> ## Documentation Index
> Fetch the complete documentation index at: https://unify-19-preview.mintlify.site/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-preview/Rc3a5wdjGKzjIQhe/images/53.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=eb67bfa6af28e9c6a93c9ead108fedf8" 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-preview/Rc3a5wdjGKzjIQhe/images/54.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=b7680858a679fff7f42a308d244eee71" 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-preview/Rc3a5wdjGKzjIQhe/images/55.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=cf4037991896f354d960749899b4745b" 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-preview/Rc3a5wdjGKzjIQhe/images/56.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=892f10ed6ff6c66f542c7c8305dc0c64" 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-preview/Rc3a5wdjGKzjIQhe/images/57.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=3fcaca1c97cd4397c535a5354c34e3ac" 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-preview/Rc3a5wdjGKzjIQhe/images/58.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=d52f7f34fa9385ef6333190f16396a35" 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-preview/Rc3a5wdjGKzjIQhe/images/59.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=49764628a4c5d232a9297b3a5592745c" 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-preview/Rc3a5wdjGKzjIQhe/images/60.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=c71cdea41859c052d2bcac4a13b652da" 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-preview/Rc3a5wdjGKzjIQhe/images/61.png?fit=max&auto=format&n=Rc3a5wdjGKzjIQhe&q=85&s=501c6616d974f2fd872ee550ad4529eb" 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-preview/3CpYj7T0TMhrXAGC/images/segment/send-option.png?fit=max&auto=format&n=3CpYj7T0TMhrXAGC&q=85&s=8198f370355fe7433920ee59e8d0cbc1" 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-preview/3CpYj7T0TMhrXAGC/images/segment/event-trigger.png?fit=max&auto=format&n=3CpYj7T0TMhrXAGC&q=85&s=de957193a3fcd0bbcbd78591540fcefb" 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-preview/3CpYj7T0TMhrXAGC/images/segment/generate-sample-event.png?fit=max&auto=format&n=3CpYj7T0TMhrXAGC&q=85&s=dadf32d40ead3d80621ac9122ba7edf1" 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-preview/3CpYj7T0TMhrXAGC/images/segment/map-fields.png?fit=max&auto=format&n=3CpYj7T0TMhrXAGC&q=85&s=4e866bf5c1566ec80fdd0b402593fe6e" 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-preview/S35maTdfAtggGuKi/images/66.png?fit=max&auto=format&n=S35maTdfAtggGuKi&q=85&s=e1b03b2323e07adef370e2f35a0b2cd6" 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.