# Rudderstack

Set up Customer.io as a Rudderstack Destination, connecting data from any of Rudderstack’s source integrations to your workspace.

 You can find the open-source transformer code for this destination in [Rudderstack’s GitHub repository](https://github.com/rudderlabs/rudder-transformer/tree/main/src/v0/destinations/customerio).

## How it works[](#how-it-works)

When you set up Customer.io as a Rudderstack Destination, Rudderstack adds, updates, and sends events representing people to Customer.io from one or more sources.

Rudderstack supports the same set of calls as [our Pipelines API](/integrations/api/cdp/), with similar payload structures. This page provides some examples of source calls you can make to forward data to Customer.io using Rudderstack’s JavaScript snippet. You’ll see Rudderstack’s complete Customer.io destination specifications [in their documentation](https://www.rudderstack.com/docs/destinations/streaming-destinations/customer.io).

For all requests, Rudderstack identifies a person by `userId` or `anonymousId`, where a `userId` matches a person’s `id` in Customer.io.

## Before you begin[](#before-you-begin)

Make sure that you’re using Rudderstack in a mode that supports your Customer.io integration. In **Cloud mode**, Rudderstack’s SDK sends events directly to Rudderstack, where they transform data and route it to Customer.io. In **Device mode**, you use a client-specific library in your app to forward information directly to Customer.io (without it going to Rudderstack first).

Before you configure this integration, consider whether or not you can support Customer.io in device or cloud mode:

Connection

Web

Mobile

Server

Device mode

✅

❌

❌

Cloud mode

✅

✅

✅

To learn more about the differences between Rudderstack’s Cloud and Device modes check out [their connection modes guide](https://www.rudderstack.com/docs/destinations/rudderstack-connection-modes/).

## Set up a Rudderstack integration[](#setup)

You’ll set up this integration almost entirely within Rudderstack. As a part of this integration, you’ll need to provide Rudderstack with your Track API credentials: your *Site ID* and *API Key*.

1.  Go to your [RudderStack dashboard](https://app.rudderlabs.com/) and click **Add Destination**.
2.  Pick Customer.io from the list of destinations, and provide a name for your new destination. If you use Rudderstack to connect with more than one workspace, you might want to name your destination for your workspace in Customer.io.
3.  Select a *Source* to connect with your destination and click **Next**.
4.  Enter the **Site ID** and **API Key** for your Customer.io workspace.
    
    You can find your Customer.io *Site ID* and *API Key* credentials under **Data & Integrations** > **Integrations** > **Customer.io API**.
    
    [![Add your Customer.io credentials in Rudderstack](https://docs.customer.io/images/rudderstack-destination-settings.png)](#ed9e416a5c5ae470e05dd4e99e5e3d2f-lightbox)
    
5.  Enter the name of the event you want to send to Customer.io when someone registers a device.
6.  (Optional) Enable *Device mode* for the web SDK if you want to send events directly from your client to Customer.io. However, you can *only* use *Device mode* with your Web implementation.
7.  Enter OneTrust category name that maps OneTrust consent settings to RudderStack’s consent purposes.
8.  Click **Next**.

Rudderstack is now set up to send events and calls into Customer.io

## Identify[](#identify)

The `identify` call sends the event data from Rudderstack to Customer.io with the properties that you pass as the RudderStack traits. For more information about identify calls, see [RudderStack’s API specification](https://rudderstack.com/docs/rudderstack-api/api-specification/rudderstack-spec/).

RudderStack sends the `createdAt` field as `created_at` in Customer.io to register user `sign up` time in the dashboard. If you don’t send `createdAt`, `created_at` is not sent in to Customer.io.

If your request doesn’t include `userId`, Rudderstack substitutes an `anonymousId`.

```javascript
rudderanalytics.identify("my-userID", {
  name: "Tintin",
  city: "Brussels",
  country: "Belgium",
  email: "tintin@herge.com"
});

// created at is not present in this request so
// Rudderstack appends the request with the current timestamp.
```

## Group[](#group)

The `group` call lets you manipulate [objectsAn object is a non-person entity that you can associate with one or more people—like a company, account, or online course.](/journeys/objects/) and relationships in Customer.io. If you have multiple object types in your system, you can specify the object type with `objectTypeId`. This defaults to `1` (the first object type in your system) if you don’t include it in your call.

The call hinges on the `action` property, which has four accepted values:

*   `identify`: adds or updates an object. If you’re using the Rudderstack JavaScript snippet, this action also relates the currently-identified user to the group.
*   `delete`: removes an object.
*   `add_relationships`: sets a relationship between the object and a user.
*   `delete_relationships`: removes a relationship between the object and a user.

```javascript
rudderanalytics.group("objectId", {
  objectTypeId: 2,
  action: "identify",
  traits: {
    classTitle: "Customer.io 101",
    teacher: "docs@customer.io"
  }
})
```

## Page[](#page)

The Customer.io JavaScript snippet captures `page` views automatically. However, if you want to pass additional properties, you can call `rudderanalytics.page()`. This sends the `page` event with additional properties that you want to pass in your `page` event.

```javascript
// "home" is the name of the page.
rudderanalytics.page("home", {
  path: "path",
  url: "url",
  title: "title",
  search: "search",
  referrer: "referrer",
});
```

## Screen[](#screen)

Rudderstack’s `screen` call records screen views for users in your app. If you turned on screen views in your Rudderstack app implementation from the [iOS](https://rudderstack.com/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-ios-sdk) or [Android](https://rudderstack.com/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-android-sdk) SDKs, these events register as `Viewed <screen name> Screen` in the *Activities* tab for the user in Rudderstack.

Rudderstack forwards the `properties` in the `screen` call to [Customer.io](https://customer.io) dashboard as it is.

Here is a sample `screen` call using RudderStack iOS SDK:

```objective-c
[[RudderClient sharedInstance] screen:@"Main"
            properties:@{@"prop_key" : @"prop_value"}];
```

## Track[](#track)

The `rudderanalytics.track()` call passes event properties to Customer.io. For more information about Rudderstack’s `track` call, see their [API specification](https://rudderstack.com/docs/rudderstack-api/api-specification/rudderstack-spec/).

```javascript
rudderanalytics.track("Track me", {
  category: "category",
  label: "label",
  value: "value",
});
```

Anonymous events cannot have a `name` over 100 bytes. Rudderstack trims event names over 100 bytes for you.

## Register device tokens from Rudderstack[](#register-device-tokens-from-rudderstack)

Rudderstack registers a `deviceToken` in [Customer.io](https://customer.io) on the following application lifecycle events:

*   `Application Installed`
*   `Application Opened`
*   `Application Unistalled`

To send device tokens to Customer.io, you need to enable `trackApplicationLifecycleEvents` in your Rudderstack SDK implementation and register users’ `deviceToken` after initializing the SDK.

Example for registering `deviceToken` is as follows:

 iOS

#### iOS[](#iOS)

```objective-c
[[[RudderClient sharedInstance] getContext] putDeviceToken:[self getDeviceToken]];
```

 Android

#### Android[](#Android)

```kotlin
rudderClient!!.rudderContext.putDeviceToken(getDeviceToken())
```