Send data from Segment to Cordial (actions) – Cordial Knowledge Base
How can we help?
Overview
With our Segment integration, you can send contact data from your Segment account to Cordial, which is seamlessly integrated into the appropriate data collections. From there you can use Cordial's powerful data and messaging tools to build audiences, personalize message content, and trigger messages across multiple channels.
- You can also send data from Cordial to Segment.
Certain features in your Cordial account must be preconfigured before the Segment integration can be enabled. Please contact your Client Success Manager for assistance before attempting to enable the integration.
Latest v. legacy version
The latest version of our integration with Segment uses the actions framework. Benefits of using the latest version include:
- Transparent data mapping: The classic Cordial destination receives data from Segment as is. The Cordial backend then converts those Segment events to Cordial’s format and clients have limited control over this conversion. The Cordial actions destination allows clients to fully define their own mappings of Segment events, making sure they receive data structured specifically for their needs.
- Only sends data you need: With the latest framework, you can define only those destination actions and mappings that make sense for your use cases, while the previous iteration always sends four predefined API calls: identify, track, group, and page.
- Sends Engage components to Cordial: With Cordial actions it’s possible to define action mappings that will send audiences and user computed traits defined in the Segment Engage platform to Cordial.
You can find documentation for the legacy (non-actions) version of our Segment integration here.
Enable latest integration version (actions framework)
Follow these steps to enable destination actions.
- Make sure you have your Cordial API Key. To create a new API key, navigate to Account Settings > API Keys.
- From the Segment web app, click Connections > Catalog.
- Search for the Cordial (Actions) destination item in the left navigation, and click it.
- Click Configure Cordial.
- Select the Source you want to connect to Cordial (Actions).
Destination settings
| Setting | Description |
|---|---|
| API key | Required. Your Cordial API key. |
| Endpoint | Required. Cordial API endpoint. Change the default to - us-west-1 - https://integrations-ingest-svc.cordial.com - us-west-2 - https://integrations-ingest-svc.usw2.cordial.com - us-east-1 - https://integrations-ingest-svc.use1.cordial.com - You can find more details in our API documentation. |
| User ID attribute key | Required. Cordial string unique attribute key to store Segment User ID in (e.g. segment_id). Note: This attribute should be the secondary key. Contact your CSM for assistance. |
Scriptable API
Our scriptable API offers asynchronous methods for sending data from Segment to Cordial. This allows you to stream data, send multiple API requests at the same time, and have more precise control over how Cordial interacts with Segment.
You can use Swagger to access and test our scriptable API offerings. In order to do so, you'll need an API key.
Supported actions
Combine supported Segment triggers with the following Cordial-supported actions.
Mapping limits per destination: individual destination instances support a maximum of 50 mappings.
- POST/segment/createContactActivity
- POST/segment/upsertContact
- POST/segment/mergeContacts
- POST/segment/addContactToList
- POST/segment/removeContactFromList
- POST/segment/addProductToCart
- POST/segment/removeProductFromCart
- POST/segment/upsertOrder
POST/segment/createContactactivity
Create a new contact activity. Default trigger is:type = "track" or type = "page"
| Parameters | Type | Description | Example |
|---|---|---|---|
| segmentIdKey | string | Segment ID key. | See example request. |
| segmentID | string | Segment user ID value. | See example request. |
| anonymousId | string | Segment anonymous ID value. | See example request. |
| userIdentities | object | An ordered list of contact identifiers in Cordial. Each item in the list represents an identifier. | See example request. |
| *action | string | Internal identifier of an action. | See example request. |
| *time | string/date-time | Action timestamp. Optional. Date format is ISO 8601 standard. If empty, the request upload time will be used. | See example request. |
| properties | object | An object of additional action attributes. Optional. | See example request. |
| context | object | Action context as it appears in Segment. Optional. We use context to capture event metadata like sender IP and device info. | See example request. |
| type | string | Type of action/event. | See example request. |
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"action": "click",
"time": "2020/24/24",
"properties": {
"test1": 1,
"test2": 2
}
}
POST/segment/upsertContact
Create or update a contact in Cordial. Default trigger:type = "identify"
| Parameters | Type | Description | Example |
|---|---|---|---|
| segmentIdKey | string | Segment ID key. | See example request. |
| segmentID | string | Segment user ID value. | See example request. |
| anonymousId | string | Segment anonymous ID value. | See example request. |
| userIdentities | object | An ordered list of contact identifiers in Cordial. Each item in the list represents an identifier. For example, channels.email.address -> userId and/or customerId -> traits.customerId. If a contact is found using the identifiers it is updated, otherwise a new contact is created. | See example request. |
| attributes | object | Contact attributes to update. Optional. Contact attributes must exist in Cordial prior to updating. Attributes that do not exist in Cordial will be ignored. Complex attribute types to be mapped via dot notation. | See example request. |
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"attributes": {
"test1": 1,
"test2": 2
}
}
POST/segment/mergeContacts
Merge contacts in Cordial. Default trigger:type = "alias"
| Parameters | Type | Description | Example |
|---|---|---|---|
| segmentIdKey | string | Segment ID key. | See example request. |
| segmentID | string | Segment user ID value. | See example request. |
| anonymousId | string | Segment anonymous ID value. | See example request. |
| *previousId | string | Previous Segment ID. | See example request. |
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"previousId": "previous-id"
}
POST/segment/addContactToList
Add contact to a list. If the list does not exist in Cordial it will be created. Default trigger:type = "group"
| Parameters | Type | Description | Example |
|---|---|---|---|
| segmentIdKey | string | Segment ID key. | See example request. |
| segmentID | string | Segment user ID value. | See example request. |
| anonymousId | string | Segment anonymous ID value. | See example request. |
| userIdentities | object | An ordered list of contact identifiers in Cordial. Each item in the list represents an identifier. | See example request. |
| *groupID | string | Internal identifier for group. | See example request. |
| listName | string | List name in Cordial. | See example request. |
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"groupId": "123",
"listName": "segmentList"
}
POST/segment/removeContactFromList
Remove contact from Cordial list.
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"groupId": "123"
}
POST/segment/addProductToCart
Adds product to cart. Default trigger:type = "track" and event = "Product Added"
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"productID": "123",
"sku": "TEST-SKU",
"qty": 2,
"category": "Test category",
"name": "Test product",
"description": "Test description",
"itemPrice": 65.32,
"url": "https://example.com/product",
"imageUrl": "https://cdn.example.com/product.jpg",
"properties": {
"variant": "black",
"size": "xs"
}
}
POST/segment/removeProductFromCart
Removes product from Cordial contact cart. Default trigger:type = "track" and event = "Product Removed"
| Parameters | Type | Description | Example |
|---|---|---|---|
| segmentIdKey | string | Segment ID key. | See example request. |
| segmentID | string | Segment user ID value. | See example request. |
| anonymousId | string | Segment anonymous ID value. | See example request. |
| userIdentities | object | An ordered list of contact identifiers in Cordial. Each item in the list represents an identifier. | See example request. |
| *productID | string | Internal identifier for a product. | See example request. |
| *qty | string | Quantity of a product. | See example request. |
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"productID": "123",
"qty": 2
}
POST/segment/upsertOrder
Upserts order to Cordial. Default trigger:event = "Order Completed" or event = "Order Updated" or event = "Order Refunded" or event = "Order Cancelled"
{
"segmentIdKey": "segment_id",
"segmentId": "test-user-ouxty4jxdm",
"anonymousId": "5cwt1zukfza",
"userIdentities": {
"cid": "test",
"email": "email"
},
"orderID": "123",
"purchaseDate": "2015-12-12T19:11:01.249Z",
"status": "Completed",
"properties": {
"tax": 32.43,
"affiliate": "Google"
},
"items": [
{
"productID": "123",
"sku": "test-sku",
"name": "test-name",
"category": "test-category",
"manufacturerName": "test-brand",
"itemPrice": 443.23,
"qty": 2,
"url": "https://example.com/product",
"imageUrl": "https://cdn.example.com/product.jpg",
"properties": {
"variant": "black",
"size": "size"
}
}
]
}
Migration from the legacy Cordial destination
User identities mappings
Every Cordial destination action needs to be invoked with data identifying a Cordial contact. To identify a contact every destination action has aUser Identitiesfield, which maps Segment event fields to Cordial contact identifiers. Each entry in the list represents a contact identifier and how it maps from a Segment event. For example,channels.email.address <- userIdorcustomerId <- traits.customerId. At least one identifier should be valid, otherwise the contact won’t be identified and the request will be ignored.
Typically, theUser Identitiesfield maps the Segment eventsuserIdfield to the Cordial secondary identifier field. For example, if Segment’suserIdfield is known to be an email, the mapping will bechannels.email.address <- userId, meaning the value ofuserIdwill be sent aschannels.email.addressto Cordial.
Update contacts
If you plan to create and update contacts in Cordial, define theupsertContactdestination action. In addition to theUser Identitiesfield, the action defines theContact Attributesfield. This field defines an exclusive set of attributes that will be updated in a contact. Typically, you map them from Segment traits. For example,customerId <- traits.customerId. For the Cordial Classic destination, these mappings are stored in Cordial’s database. In the Cordial (Actions) destination, they become explicit in theupsertContactdestination action mappings.
Send events
To send events, define thecreateContactactivitydestination action. In addition to theUser Identitiesfield, additional fields such asEvent name,Event timestamp, andEvent propertiesmay be defined. Refer to documentation for each field when defining the destination action.
Add and remove users from lists
If you plan to segment users in Cordial, make sure you define theaddContactToListandremoveContactFromListdestination actions. Both actions require the Segment group ID.addContactToListoptionally accepts a list name.
Although optional, you should consider the list name as a required option, because it simplifies segmenting contacts in Cordial based on lists. Lists without a name are called following thesegment_[groupId]pattern.