Segment: Customer.io as a data source

Updated

Set up Customer.io as a Segment Source to pipe data out of Customer.io and into any one of Segment’s hundreds of Destination integrations. This integration sends data to Segment in track() calls. You can send any event supported by our reporting webhooks to Segment.

 Disable and re-enable this integration to gain access to new features!

We updated this integration in May of 2022. If you enabled your Segment Source integration before then, disable the integration and re-enable it to gain access to new events and settings.

Enable Customer.io as a Segment source

To enable Customer.io as a Segment source, you need both a Customer.io and a Segment.com account. If you are creating a new Segment account, enter “Customer.io” in the How Did You Hear About Us? field.

 We send anonymous events for people who do not have an ID

If a person has an ID, we send events with the ID as the Segment userId. If a person has an email address but does not have an ID, we send anonymous events with the email address as the anonymousId.

  1. In the Segment interface, Go to Connections, click Add Source, and select Customer.io.

  2. Give your source a Name and a Label, and click Add Source. The Name helps you identify your source in Segment, and the label helps you organize sources in your Segment workspace.

    Segment Sources setup
    Segment Sources setup

  3. On the Overview page, copy your Write Key.

    Segment Sources write key
    Segment Sources write key

  4. In your Customer.io workspace, go to Data & Integrations > Integrations and select the Segment Source integration. You can find it in the Data Management category.

  5. Paste your Write Key in the field and click Connect Segment.

  6. Enable the events you want to send from Customer.io to Segment.

    Select events to send to segment
    Select events to send to segment

  7. Set your integration options:

    • Send Frequency: Determine whether to send every instance of every event or only the first time an event occurs.
    • Body Content: Enable this to include your message’s body content in all of the “Sent” events we send to you.
    • Send segment events back to Customer.io destinations: This setting lets you send events from Customer.io, as a Segment source, back to Customer.io as a Segment destination. In general, we suggest that you leave this feature disabled. The data you send to Segment is already available in Customer.io. Learn more.
    • Segment Data Ingestion Region: Set the region you want to ingest data into.
  8. In Segment, turn on the destinations you want to send your Customer.io data to.

How we map people to Segment

Our Segment Source integration maps a person’s id in Customer.io to userId in Segment.

If your Customer.io workspace supports both email and id as identifiersThe attributes you use to add, modify, and target people. Each unique identifier value represents an individual person in your workspace., people in your workspace can have an email but not an id. In this case, we use a person’s email as their anonymousId in Segment.

For more information about identifying people, see Segment’s Identify API.

analytics.track("New Lead", {
  anonymousId: "peter@example.com"
  name: "Peter Gibbons",
  email: "peter@example.com"
});
analytics.track("New Customer", {
  userId: "97980cfea0067",
  name: "Peter Gibbons",
  email: "peter@example.com",
  plan: "premium"
});

Send segment events back to Customer.io destinations

We give you the option to feed events from your source back to Customer.io destinations. In general, you should not enable this option. The data that you send to Segment is already available in your workspace. Sending it back to your workspace simply makes this data available as events.

Rather than looping events back into your workspace, you can use our data-driven segment builderA group of people who match a series of conditions. People enter and exit the segment automatically when they match or stop matching conditions. to trigger campaigns based on your Message Data. You can then trigger campaigns based on the ways in which people respond to your messages without sending duplicate data back into your workspace.

Segment people based on message actions
Segment people based on message actions

Track Payloads: confirm that your Segment Source works

You can confirm that your Customer.io Source is working by sending yourself a test campaign and checking the debugger. Customer.io can send any of our reporting webhook events to Segment, reshaped specifically for Segment’s track calls. We’ve provided some examples below to help you understand the information that you’ll see in Segment.

If you enable the Body Content setting, the events below will also include a data.content key representing the body of your message.

 If a person doesn’t have an ID, we send anonymousId

The payloads below all show users with an ID, which we pass to Segment as a userId. If a person doesn’t have an ID, userId will be an empty string and the payload will include an anonymousId populated with the person’s email address.

Email Opened

 Only sent events contain content

If you enable the Include body content in all Sent events setting, Email Sent events will contain body content. For all other email events, content is null.

{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "2.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Email Opened",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21CJeZPJX3TdLhPNrzstyAYZa",
  "originalTimestamp": "2021-06-16T13:04:06Z",
  "properties": {
    "action_id": 16,
    "campaign_id": 1,
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "journey_id": "01G2NBFT8N2MYDTT3MHWK7Z6C6",
    "subject": "Test Subject",
    "content": null, //null unless Body Content is enabled and event is Email Sent
    "recipient": "cool.person@customer.io",
    "userId": "cool-person"
  },
  "receivedAt": "2021-06-16T13:05:39.605Z",
  "sentAt": "2021-06-16T13:05:39.000Z",
  "timestamp": "2021-06-16T13:04:06.605Z",
  "type": "track",
  "userId": "cool-person",
  "writeKey": "aSOzeRCalHEDr3H5BslyxT4G35vDJBna"
}
SMS Sent
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "2.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "SMS Sent",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-28wdXq0yQP8jesjRYdLmj2dxiaM",
  "originalTimestamp": "2022-05-09T21:27:02.000Z",
  "properties": {
    "action_id": 41,
    "anonymousId": "cool.person@example.com",
    "campaign_id": 7,
    "content": "Hey, just testing sms segment stuff.",
    "delivery_id": "RKGZAQACAYCqt-kVejTLzrd-t9D_sQ==",
    "journey_id": "01G2NBFT8N2MYDTT3MHWK7Z6C6",
    "recipient": "15555555555",
    "userId": "cool.person@example.com"
  },
  "receivedAt": "2022-05-09T21:27:03.384Z",
  "sentAt": "2022-05-09T21:27:03.151Z",
  "timestamp": "2022-05-09T21:27:02.233Z",
  "type": "track",
  "userId": "karn@customer.io",
  "writeKey": "aSOzeRCalHEDr3H5BslyxT4G35vDJBna"
}
SMS Link Clicked
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "2.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "SMS Link Clicked",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u242Y8g1XCtEl9rEp7NwBx3K9o",
  "originalTimestamp": "2021-06-16T13:29:01Z",
  "properties": {
    "action_id": "n18",
    "campaign_id": 3,
    "delivery_id": "dgP6xQb6xQYDAAF6FQJvh4yaVoIOMGeCVp4=",
    "content": null, //null if Body Content is disabled
    "journey_id": "01G2NBFT8N2MYDTT3MHWK7Z6C6",
    "recipient": "15555555555",
    "userId": "cool.person@example.com",
    "link": {
      "id": 1,
      "url": "https://customer.io/features"
    }
  },
  "receivedAt": "2021-06-16T13:29:03.021Z",
  "sentAt": "2021-06-16T13:29:02.000Z",
  "timestamp": "2021-06-16T13:29:02.021Z",
  "type": "track",
  "userId": "cool-person",
  "writeKey": "aSOzeRCalHEDr3H5BslyxT4G35vDJBna"
}
Push Sent
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "2.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Push Sent",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21CJeZPJX3TdLhPNrzstyAYZa",
  "originalTimestamp": "2021-06-16T13:04:06Z",
  "properties": {
    "action_id": "n16",
    "campaign_id": 1,
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "journey_id": "01G2NBFT8N2MYDTT3MHWK7Z6C6",
    "recipients": [
      {
        "device_id": "15ad6c7ddc29f1d6a28580b040ddddfb831fd009bafac1dff718be7ed4233c15",
        "device_platform": "ios"
        
      }
    ],
    "userId": "cool.person@example.com"
  },
  "receivedAt": "2021-06-16T13:05:39.605Z",
  "sentAt": "2021-06-16T13:05:39.000Z",
  "timestamp": "2021-06-16T13:04:06.605Z",
  "type": "track",
  "userId": "cool-person",
  "writeKey": "aSOzeRCalHEDr3H5BslyxT4G35vDJBna"
}
Slack Sent
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "2.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "sales@example.com"
    }
  },
  "event": "Slack Sent",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21CJeZPJX3TdLhPNrzstyAYZa",
  "originalTimestamp": "2021-06-16T13:04:06Z",
  "properties": {
    "action_id": "n16",
    "campaign_id": 1,
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "journey_id": "01G2NBFT8N2MYDTT3MHWK7Z6C6",
    "recipient": "#cool-channel",
    "userId": "cool.person@example.com"
  },
  "receivedAt": "2021-06-16T13:05:39.605Z",
  "sentAt": "2021-06-16T13:05:39.000Z",
  "timestamp": "2021-06-16T13:04:06.605Z",
  "type": "track",
  "userId": "sales-team",
  "writeKey": "aSOzeRCalHEDr3H5BslyxT4G35vDJBna"
}
Webhook Sent
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "2.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Webhook Sent",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21MrfL8kIJwhuNanhhBbuc9gq",
  "originalTimestamp": "2021-06-16T13:05:55Z",
  "properties": {
    "action_id": "n17",
    "campaign_id": 2,
    "delivery_id": "dgP6xQb6xQYDAAF6FOsF0yqZiIo1NgezYcI=",
    "journey_id": "01G2NBFT8N2MYDTT3MHWK7Z6C6",
    "recipient": "https://example.com/webhook-url",
    "userId": "cool.person@example.com"
  },
  "receivedAt": "2021-06-16T13:07:04.404Z",
  "sentAt": "2021-06-16T13:07:04.000Z",
  "timestamp": "2021-06-16T13:05:55.404Z",
  "type": "track",
  "userId": "cool-person",
  "writeKey": "aSOzeRCalHEDr3H5BslyxT4G35vDJBna"
}

If events flow into your Segment debugger, you’ll know that the Source is properly enabled.

segment_sources_debugger.png
segment_sources_debugger.png

Upgrade your integration

If you had the previous iteration of this integration enabled, you were only able to send email events to Segment. To update your integration to version 2.0, disable the integration and then re-enable it. When you re-enable the integration, you’ll have access to the new event types and other settings made available in May of 2022.

An upgraded Segment Source integration
An upgraded Segment Source integration

Differences between versions 1.0 and 2.0

When updating from version 1.0 to 2.0, you’ll notice the following changes:

  • version is incremented from 1.0.0 to 2.0.0.
  • email_id is no longer included in Email events. This field duplicated the delivery_id.
  • When you enable Body Content for email events, email_subject has changed to simply subject.
  • Events no longer include action_name, campaign_name, newsletter_name, or transactional_message_name. We’ve removed these items to improve performance. Instead, you can retrieve these values using the corresponding object id (ie campaign_id) and our App API.

Need help?

Copied to clipboard!
  Contents
Is this page helpful?