Legacy Segment integration: non-actions framework – Cordial Knowledge Base

How can we help?

Search

The Segment integration documented on this page is the legacy (non-actions) version. We recommend using the latest (actions) version.

Segment contact data types

Here are the types of Segment contact data Cordial ingests using the non-actions (classic) framework:

Enable Segment as a source

Complete these steps to activate the destination using the Cordial API key as well as enable the integration via API call.

Activate the destination using Cordial API key

  1. Create an API key in your Cordial account using the wildcard IP address of: 0.0.0.0/0. Learn more about creating API keys in Cordial here.

  2. Log in to your Segment account.

  3. Once logged in, paste this URL into your browser: https://app.segment.com/WORKSPACE/destinations/catalog/cordial

  1. Paste your Cordial API key and select Activate Destination.

Certain Cordial attributes designated to store Segment attribute values may need to be created as unique and sparse index fields. Please contact your Client Success Manager for additional assistance.

Enable the integration using an API call

In order to enable the integration in your Cordial account, you must make the following API call:

POST https://admin.cordial.io/api/integrations/segment

Method URI Path
POST https://admin.cordial.io/api/integrations/segment
Enables the Segment integration using the appropriate JSON body.

Parameters

* Required

Parameter Type Description Example
*name string The name of the integration to be enabled. "segment" should be used to enable the Segment integration. segment
*enabled boolean Enables or disables the integration. true or false

Supported Segment functions

Cordial supports the identify, track, group, and page methods.

Identify

Segment data is passed through to Cordial using this endpoint, where 'user' in the URL parameters should be set to the Segment API key. The userId in the dataset will be saved to a Cordial attribute designated to store the Segment identifier.

Group

Supported data parameters

Segment key Type Cordial mapping
userId string Primary or secondary contact identifier value such as cID, email or a custom identifier.
groupId string list ID

Make sure there is a minimum delay of five seconds between the Identify call and the Group call for new users.

Cordial lists: add or remove contacts

To make the process of adding and removing contacts from existing Cordial lists more efficient, the list names can be prefixed by grp_ and passed as traits of an identify call. Lists prefixed by grp_ accept the following values: 1 and 0 or true and false to indicate if a contact should be added or removed from the list.

The example below demonstrates how to add a new contact to existing Cordial WelcomeSeries and NewUsers lists. To remove a contact from your lists instead, simply use 0 or false values in place of 1 and true.

"traits": {
"grp_WelcomeSeries": 1,
"grp_NewUsers": true
}

Track

Supported data parameters

Segment key Type Cordial mapping
userId string Primary or secondary contact identifier value such as cID, email or custom identifier.
event string Event name.
properties object Event properties (optional).

Page

Supported data parameters

Segment key Type Cordial mapping
userId string Primary or secondary contact identifier value such as cID, email or custom identifier.

Optional advanced configuration

PUT https://admin.cordial.io/api/integrations/segment

Method URI Path
PUT https://admin.cordial.io/api/integrations/segment
Updates the Segment integration using the appropriate JSON body.
You can remap segment fields using the optional attributeMapping parameter.

Parameters

* Required

Parameter Type Description Example
attributeMapping Comma separated array of two name/value pairs. Used to remap Segment fields to Cordial attribute keys. true or false
ignoreFields Array of comma separated values. Used to blacklist Segment fields from being passed to Cordial. ["website"]

Example JSON request (with attributeMapping and ignoreFields)

The following will remap Segment fields to existing Cordial attribute keys and ignore the "website" field.

{
    "name":"segment",
    "enabled":true,
    "attributeMapping":[
        {"segmentField":"first_name","cordialKey":"fname"},
        {"segmentField":"user_id","cordialKey":"extid"},
        {"segmentField":"address.state","cordialKey":"state"},
        {"segmentField":"email","cordialKey":"channels.email.address"}
    ],
    "ignoreFields":["website"]
}

GET https://admin.cordial.io/api/integrations

Retrieve a JSON list of integrations you have set up with Cordial.