# Segment

[Segment](https://segment.com/?utm_source=Synap\&utm_medium=SynapSegmentHelpDocs\&utm_campaign=synap_recommending_segment\&utm_id=fromSynap) is a fantastic platform and one we highly recommend. Segment unifies all of your data and makes sure its ready to go into other tools in the right way. Using segments means you don't need to installing different codes onto your website / portals in order to connect it to other tools.&#x20;

A really common integration is connecting Synap (Source see [Segment docs on Sources](https://segment.com/docs/connections/sources/?utm_source=Synap\&utm_medium=SynapSegmentHelpDocs\&utm_campaign=synap_recommending_segment\&utm_id=fromSynap#what-is-a-source)) to a chat widget like [Intercom ](https://www.intercom.com/)(Destination see [Segment docs on Destinations](https://segment.com/docs/connections/destinations/?utm_source=Synap\&utm_medium=SynapSegmentHelpDocs\&utm_campaign=synap_recommending_segment\&utm_id=fromSynap)) you can also :&#x20;

* ![:bar\_chart:](https://a.slack-edge.com/production-standard-emoji-assets/14.0/apple-medium/1f4ca.png) Analytical tools such as Google Analytics, Mixpanel & Localytics
* 💬 Support/Engagement platforms such as Intercom, Aircall, Mailchimp & Salesforce
* 📣 Advertisement tools such as Facebook & Google Ads

If you already have a Segment account, create a new source for Synap add in the URL. Once the source is set up, copy the Write key

<figure><img src="https://3316915154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkgvUeCmTPeNouRxGPC%2Fuploads%2FRo0RiqT03ChCkqDkwPK4%2FScreenshot%202024-05-10%20at%2010.42.57.png?alt=media&#x26;token=b4b57e55-e646-431b-b66d-e7550238369c" alt=""><figcaption><p>Synap in Segment </p></figcaption></figure>

Head over to **Settings > Integrations.** From here you'll see a box to input your Segment Write key.&#x20;

![Settings > Integrations](https://3316915154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkgvUeCmTPeNouRxGPC%2Fuploads%2Fr2vBQh7f98H5cve9J2eS%2FScreenshot%202021-11-11%20at%2010.20.19.png?alt=media\&token=ba301d1a-ae0d-4862-a4b1-6264260f6459)

### Event Data

Segment lets you view event data for key events on Synap. You can use Segment's [Track](https://segment.com/docs/connections/spec/track/) and [Page](https://segment.com/docs/connections/spec/page/) events to see what users are doing and what page they're on.  Then through Segment's [Identify](https://segment.com/docs/connections/spec/identify/) tie those events back to users.&#x20;

![Using identify to link users to events in Segment](https://3316915154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkgvUeCmTPeNouRxGPC%2Fuploads%2F2CRH1SwxB7CGXL9r0Ld6%2Fimage.png?alt=media\&token=0fac6dd4-da3c-4985-94c9-3e3f0ac72fc8)

#### Identify&#x20;

Attributes attached to the user will show in Segment as `EI-` see below for an example of an Identify call payload.

```json
{
  "userId": "QsogF1GDFZ",
  "traits": {
    "EI-Role": "Health and Safety Manager",
    "createdAt": "new Date('2021-11-26T10:09:52.447Z')",
    "email": "homer_simpson@spfield.com",
    "emailVerified": false,
    "firstName": "Homer",
    "lastName": "Simpson",
    "marketingEmailsConsent": "removed",
    "name": "Homer Simpson",
    "profilePicture": "https://upload.wikimedia.org/wikipedia/en/0/02/Homer_Simpson_2006.png"
  }
}
```

#### Track

Began test is an example of a Track event, it is linked to the user using their `userId` these events tend to exclude titles and rely on `testId` and `attemptId` Note: an `attemptId` is a users unique attempt on a particular `testId`

```json
{
  "event": "Began Test",
  "integrations": {},
  "messageId": "node-xxxxxxxxxx",
  "originalTimestamp": "2022-01-18T18:37:43.245Z",
  "properties": {
    "Quiz Mode": "test",
    "attemptId": "rae6sql3AD",
    "testId": "RG70wQdFDl"
  },
  "receivedAt": "2022-01-18T18:37:43.872Z",
  "sentAt": "2022-01-18T18:37:43.246Z",
  "timestamp": "2022-01-18T18:37:43.871Z",
  "type": "track",
  "userId": "QsogF1GDFZ"
}
```

#### Page

Page calls will show the page path and unique URL. Synap content pages will always contain an identifier in the url ie:&#x20;

* /collections/&#x20;
* /assignment/
* /quiz/
* /insights/

```json
{
  "name": "Springfield Portal",
  "path": "/quiz/a/rae6sql3AD",
  "referrer": "",
  "search": "?title=Springfield%Exam",
  "title": "Springfield Summer Exam",
  "url": "https://portal.synap.ac/quiz/a/rae6sql3AD?title=Springfield%Exam"
}
```

Segment has a lot of documentation and resources, if you're interested they have a free online university to help you get started: [Segment University](https://university.segment.com/introduction-to-segment/299968)
