# Email

> Handles attribution and interaction tracking for Segmentify email campaigns.

Handles attribution and interaction tracking for Segmentify email campaigns. These events must be sent when a user arrives on your site via an email campaign link where `utm_medium=email`.

Before sending any of these events, verify that the campaign URL contains the required UTM parameters: `utm_source=segmentify`, `utm_medium=email`, `utm_campaign=eml_xxxx`, and `utm_code=xxxxxxxx`.

**Requests:**
- **Email View** — fires when the user lands on the site from an email link. Uses `type: "email"` and sets both `instanceId` and `interactionId` to `{emailCampaignId}` (the `utm_campaign` value).
- **Email Click** — fires when the user clicks a product or recommendation shown as a result of the email campaign. Uses `type: "click"` with `instanceId` set to the campaign ID and `interactionId` set to the clicked `{productId}`.
- **Email User Op** — identifies the arriving user by linking their session to a known email identity. Uses `name: "USER_OPERATIONS"`, `step: "identify"`, `channel: "email"`, and `identity: {utm_code}` (the hash from the campaign URL).

## Email View

### Email View Event

Send this event when a user **opens or views an email** sent by a Segmentify email campaign. This event must be fired as soon as the user lands on your website via an email campaign link where `utm_medium=email`.

> ⚠️ **Important:** Before sending this event, make sure the email campaign URL contains the following UTM parameters: 

---

#### Endpoint

`POST https://{dataCenterUrl}.segmentify.com/add/events/v1.json?apiKey={apikey}`

---

#### Request Body Fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | ✅ | Event name. Must be `INTERACTION`. |
| `userId` | string | ✅ | Unique identifier for the user. |
| `sessionId` | string | ✅ | Unique identifier for the current session. |
| `testMode` | string | ✅ | Set to `"false"` for production events. |
| `device` | string | ✅ | Device type of the user (e.g., `DESKTOP`, `MOBILE`, `TABLET`). |
| `lang` | string | ✅ | Language code (e.g., `en`, `tr`). |
| `currency` | string | ✅ | Currency code (e.g., `USD`, `EUR`, `TRY`). |
| `region` | string | ❌ | Region or country code of the user. |
| `email` | string | ✅ | Email address of the user who received the campaign. |
| `type` | string | ✅ | Interaction type. Fixed value: `"email"`. |
| `interactionId` | string | ✅ | The email campaign ID. Use the `utm_campaign` value from the email link. Maps to `{emailCampaignId}`. |
| `instanceId` | string | ✅ | The email campaign instance ID. Same as `interactionId`. Maps to `{emailCampaignId}`. |

**Example body**

```json
{
  "name": "INTERACTION",
  "userId": "1234567890123456789",
  "sessionId": "9876543210987654321",
  "testMode": "false",
  "device": "PC",
  "lang": "EN",
  "currency": "EUR",
  "region": "",
  "email": "user@example.com",
  "type": "email",
  "interactionId": "eml_xxxx",
  "instanceId": "eml_xxxx"
}
```

:::tip[Try it]
Send this request from the [Events API reference](/reference/events/): pick **Email / Email View** in the request body examples of *Send events*.
:::


## Email Click

### Email Click Event

Send this event when a user **clicks on a product or recommendation** within a Segmentify email campaign. This event tracks which products the user interacted with after arriving from an email link where `utm_medium=email`.

> ⚠️ **Important:** Before sending this event, make sure the email campaign URL contains the following UTM parameters:
> - `utm_source=segmentify`
> - `utm_medium=email`
> - `utm_campaign=eml_xxxx`
> - `utm_code=xxxxxxxx`

---

#### Endpoint
`POST https://{dataCenterUrl}.segmentify.com/add/events/v1.json?apiKey={apikey}`

---

#### Request Body Fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | ✅ | Event name. Must be `INTERACTION`. |
| `userId` | string | ✅ | Unique identifier for the user. |
| `sessionId` | string | ✅ | Unique identifier for the current session. |
| `testMode` | string | ✅ | Set to `"false"` for production events. |
| `device` | string | ✅ | Device type (e.g., `DESKTOP`, `MOBILE`, `TABLET`). |
| `params` | object | ❌ | Additional custom parameters. Can be left empty `{}`. |
| `recommendIds` | array | ❌ | IDs of recommendations shown in the email. |
| `pageUrl` | string | ❌ | Full URL of the page the user landed on after clicking. |
| `referrer` | string | ❌ | URL of the referring page. |
| `lang` | string | ✅ | Language code (e.g., `en`, `tr`). |
| `currency` | string | ✅ | Currency code (e.g., `USD`, `EUR`, `TRY`). |
| `region` | string | ❌ | Region or country code of the user. |
| `type` | string | ✅ | Interaction type. Fixed value: `"click"`. |
| `instanceId` | string | ✅ | The email campaign ID. Maps to `{emailCampaignId}`. |
| `interactionId` | string | ✅ | The ID of the product that was clicked in the email. Maps to `{productId}`. |
| `email` | string | ✅ | Email address of the user who received the campaign. |

**Example body**

```json
{
  "name": "INTERACTION",
  "userId": "1234567890123456789",
  "sessionId": "9876543210987654321",
  "testMode": "false",
  "device": "PC",
  "params": {},
  "recommendIds": [],
  "pageUrl": "",
  "referrer": "",
  "lang": "EN",
  "currency": "EUR",
  "region": "",
  "type": "click",
  "instanceId": "eml_xxxx",
  "interactionId": "PRODUCT_ID",
  "email": "user@example.com"
}
```

:::tip[Try it]
Send this request from the [Events API reference](/reference/events/): pick **Email / Email Click** in the request body examples of *Send events*.
:::


## Email User Op

### Email User Op Event

Send this event to **identify the user** who arrived via a Segmentify email campaign link. This event links the anonymous user session to a known email identity using the `utm_code` hash from the campaign URL. It must be fired when `utm_medium=email` is detected in the URL.

> ⚠️ **Important:** The `identity` field must be populated with the `utm_code` value from the email campaign URL. This is a unique hash that Segmentify uses to identify the recipient.
>
> Example URL parameter: `utm_code=UTM_CODE_HASH`

---

#### Endpoint
`POST https://{dataCenterUrl}.segmentify.com/add/events/v1.json?apiKey={apikey}`

---

#### Request Body Fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | ✅ | Event name. Must be `USER_OPERATIONS`. |
| `userId` | string | ✅ | Unique identifier for the user. |
| `sessionId` | string | ✅ | Unique identifier for the current session. |
| `device` | string | ✅ | Device type (e.g., `DESKTOP`, `MOBILE`, `TABLET`). |
| `lang` | string | ✅ | Language code (e.g., `en`, `tr`). |
| `currency` | string | ✅ | Currency code (e.g., `USD`, `EUR`, `TRY`). |
| `region` | string | ❌ | Region or country code of the user. |
| `email` | string | ❌ | Email address of the user (if known at this point). |
| `step` | string | ✅ | Operation step. Fixed value: `"identify"`. |
| `channel` | string | ✅ | The channel through which the user arrived. Fixed value: `"email"`. |
| `type` | string | ✅ | Identity type. Fixed value: `"sgm-hash"`. |
| `identity` | string | ✅ | The `utm_code` hash value extracted from the email campaign URL. Maps to `{utm_code}`. |

**Example body**

```json
{
  "name": "USER_OPERATIONS",
  "userId": "1234567890123456789",
  "sessionId": "9876543210987654321",
  "device": "PC",
  "domain": "https://www.example.com",
  "lang": "EN",
  "email": "",
  "step": "identify",
  "channel": "email",
  "type": "sgm-hash",
  "identity": "UTM_CODE_HASH"
}
```

:::tip[Try it]
Send this request from the [Events API reference](/reference/events/): pick **Email / Email User Op** in the request body examples of *Send events*.
:::
