Segment: Customer.io as a data Source

Set up Customer.io as a Segment Source, piping email data out of Customer.io and into any one of Segment’s hundreds of Destination integrations. Data is sent to Segment in track() calls.

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 click 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. In Segment, turn on the destinations you want to send your Customer.io data to.

How we map people to Segment

We map people’s IDs in Customer.io to userId in Segment. However, if your Customer.io workspace identifies people by email or ID, people in your workspace might have an email but not an id.

In this case, we pass the email for a person in Customer.io as the anonymousId in Segment. This allows us to send events for all people, even people without IDs, to Segment. Within Segment, you can ignore these events or map them to another destination.

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"
});

Track Payloads: confirm that your Segment Source works

You can confirm that your Customer.io Source is working by sending a test campaign to yourself and checking the debugger. Customer.io sends the following events to Segment. Click any event to see an example of the track payload for each event type.

 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, the payload will not have a userId. Instead, the payload will have an anonymousId populated with the person’s email address.

Email Delivered
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "1.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Email Delivered",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21CJeZPJX3TdLhPNrzstyAYZa",
  "originalTimestamp": "2021-06-16T13:04:06Z",
  "properties": {
    "action_id": "n16",
    "action_name": "Test Name",
    "campaign_id": 1,
    "campaign_name": "Test Name",
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_subject": "Test Subject"
  },
  "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"
}
Email Opened
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "1.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": "n16",
    "action_name": "Test Name",
    "campaign_id": 1,
    "campaign_name": "Test Name",
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_subject": "Test Subject"
  },
  "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"
}
Email Link Clicked
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "1.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Email Link Clicked",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u242Y8g1XCtEl9rEp7NwBx3K9o",
  "originalTimestamp": "2021-06-16T13:29:01Z",
  "properties": {
    "action_id": "n18",
    "action_name": "Test Name",
    "campaign_id": 3,
    "campaign_name": "[Copy] [Copy] Test Name",
    "delivery_id": "dgP6xQb6xQYDAAF6FQJvh4yaVoIOMGeCVp4=",
    "email_id": "dgP6xQb6xQYDAAF6FQJvh4yaVoIOMGeCVp4=",
    "email_subject": "Test Subject",
    "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"
}
Email Marked as Spam
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "1.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Email Spammed",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21CJeZPJX3TdLhPNrzstyAYZa",
  "originalTimestamp": "2021-06-16T13:04:06Z",
  "properties": {
    "action_id": "n16",
    "action_name": "Test Name",
    "campaign_id": 1,
    "campaign_name": "Test Name",
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_subject": "Test Subject"
  },
  "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"
}
Email Bounced
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "1.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Email Bounced",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21CJeZPJX3TdLhPNrzstyAYZa",
  "originalTimestamp": "2021-06-16T13:04:06Z",
  "properties": {
    "action_id": "n16",
    "action_name": "Test Name",
    "campaign_id": 1,
    "campaign_name": "Test Name",
    "delivery_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_id": "dgP6xQb6xQYDAAF6FOl-vmR0E7zoPqTRiAo=",
    "email_subject": "Test Subject"
  },
  "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"
}
Unsubscribed
{
  "context": {
    "integration": {
      "name": "customer.io",
      "version": "1.0.0"
    },
    "library": {
      "name": "unknown",
      "version": "unknown"
    },
    "traits": {
      "email": "cool.person@example.com"
    }
  },
  "event": "Unsubscribed",
  "integrations": {
    "Customer.io": false
  },
  "messageId": "api-1u21MrfL8kIJwhuNanhhBbuc9gq",
  "originalTimestamp": "2021-06-16T13:05:55Z",
  "properties": {
    "action_id": "n17",
    "action_name": "Test Name",
    "campaign_id": 2,
    "campaign_name": "[Copy] Test Name",
    "delivery_id": "dgP6xQb6xQYDAAF6FOsF0yqZiIo1NgezYcI=",
    "email_id": "dgP6xQb6xQYDAAF6FOsF0yqZiIo1NgezYcI=",
    "email_subject": "Test Subject"
  },
  "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"
}

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

segment_sources_debugger.png
segment_sources_debugger.png

Need help?

Copied to clipboard!