# Cordial Cloud Mode Integration

After you have successfully instrumented Cordial as a destination in RudderStack, follow this guide to correctly send your events to Cordial in [cloud mode]({{< ref "/destinations/rudderstack-connection-modes.md#cloud-mode" >}}).

Find the open source transformer code for this destination in the [GitHub repository](https://github.com/rudderlabs/rudder-transformer/tree/main/src/cdk/v2/destinations/cordial/).

## Identify

You can use the [`identify`]({{< ref "event-spec/standard-events/identify.md" >}}) call to create or update a contact in Cordial. RudderStack uses the [Contacts API](https://support.cordial.com/hc/en-us/articles/203885958-Contacts-API) to send this data.

{{< info >}}
Make sure to create the contact attributes in the Cordial dashboard before sending them in your `identify` events.
{{< /info >}}

A sample `identify` call is shown:

```javascript
rudderanalytics.identify("1hKOmRA4GRlm", {
  name: "Alex Keener",
  email: "alex@example.com",
  logins: 2,
}, {
  externalId: [{
    type: "cordialContactId",
    id: "12345"
  }, ],
});
```

### Supported mappings

RudderStack maps the following `identify` fields to the corresponding Cordial properties:

| RudderStack property | Cordial property | Note |
| :----| :----|  :----|
| `traits.email` <br/>`context.traits.email`<br /> <span style="color: #4D4DFF;font-size:12px;">Either `email` or `externalId.id` is required. </span> | `channels.email.address` | - |
| `context.externalId.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Either `email` or `externalId.id` is required. </span>  | `cID` |  `externalId.type` should be set to `cordialContactId` (Cordial-generated database identifier). | 
| `traits.subscribedStatus` <br /> `context.traits.subscribeStatus` | `channels.email.subscribeStatus` | 
| `traits` | `attributes` | User traits except the `email` and `subscribeStatus` fields. |

## Track

You can use the [`track`]({{< ref "event-spec/standard-events/track.md" >}}) call to track and create a contact's activity in Cordial. RudderStack uses the [Contact Activities](https://support.cordial.com/hc/en-us/articles/203885968-Contact-activities-events-API#postContactActivities) API to send this data.

{{< info >}}
Make sure to create a contact in Cordial using an `identify` call before sending the `track` events for that contact.
{{< /info >}}

A sample `track` call is shown:

```javascript
rudderanalytics.track(
  "Product Reviewed", {
    review_id: "86ac1cd43",
    product_id: "9578257311",
    rating: 4.0,
    review_body: "Good product.",
  }, {
    externalId: [{
      type: "cordialContactId",
      id: "12345",
    }, ],
  },
);
```

{{< warning >}}
Cordial has [reserved some event names](https://support.cordial.com/hc/en-us/articles/203885968-Contact-activities-events-API#reservedEvents:~:text=Actions%20taken%20within%20a%20message%20(reserved%20actions)%20will%20automatically%20generate%20an%20activity%20record.%20These%20include%3A) that automatically generate an activity record. Hence, do not use these names while sending your `track` events to Cordial.
{{< /warning >}}

### Supported mappings

RudderStack maps the following `track` fields to the corresponding Cordial properties:

| RudderStack property | Cordial property | Note |
| :----| :----|  :---| 
| `event` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span>  | `a` |  - |
| `context.externalId.id` <br /> `traits.email` <br />`context.traits.email` <br/> <span style="color: #4D4DFF;font-size:12px;">Required </span>   | `contact identifier` |  `externalId.type` should be set to `cordialContactId` (Cordial-generated database identifier). | 
| `properties` | `properties` | -  |
| `timestamp` <br /> `originalTimestamp` | `ats` | ISO 8601 date in the format `yyyy-MM-ddTHH:mm:ss.SSSZ`. <br /><br />For example: `2022-02-01T19:14:18.381Z` |


