Identify people

Updated

Use CustomerIO.identify() to identify a person. You need to identify a mobile user before you can send them messages or track events for things they do in your app.

Identify a person

Identifying a person:

  1. Adds or updates the person in your workspace. This is basically the same as an identify call to our server-side API.

  2. Saves the person’s information on the device. Future calls to the SDK reference the identified person. For example, after you identify a person, any events that you track are automatically associated with that person.

  3. Associates the current device token with the the person.

You can only identify one customer at a time. The SDK “remembers” the most recently-identified customer. If you identify person A, and then call the identify function for person B, the SDK “forgets” person A and assumes that person B is the current app user. You can also stop identifying a person, which you might do when someone logs off or stops using your app for a significant period of time.

An identify request takes two parameters:

import { CustomerIO } from "customerio-reactnative";

// Call this method whenever you are ready to identify a user
CustomerIO.identify({
    userId: "user_id", 
    traits: {
        first_name: "user_name",
        email: "email_identifier",
    },
});

Update a person’s attributes

You store information about a person in Customer.io as attributesA key-value pair that you associate with a person or an object—like a person’s name, the date they were created in your workspace, or a company’s billing date etc. Use attributes to target people and personalize messages. Attributes are analogous to traits in Data Pipelines.. When you call the CustomerIO.identify() function, you can update a person’s attributes on the server-side.

If a person is already identified, and then updates their preferences, provides additional information about themselves, or performs other attribute-changing actions, you can update their attributes with setProfileAttributes.

You only need to pass the attributes that you want to create or modify to setProfileAttributes. For example, if you identify a new person with the attribute ["first_name": "Dana"], and then you call CustomerIO.setProfileAttributes = ["favorite_food": "pizza"] after that, the person’s first_name attribute will still be Dana.

const profileAttributes = {
    favouriteFood: "Pizza",
    favouriteDrink: "Mango Shake"
};
CustomerIO.setProfileAttributes(profileAttributes)    

Device attributes

By default (if you don’t set .autoTrackDeviceAttributes(false) in your config), the SDK automatically collects a series of attributesA key-value pair that you associate with a person or an object—like a person’s name, the date they were created in your workspace, or a company’s billing date etc. Use attributes to target people and personalize messages. Attributes are analogous to traits in Data Pipelines. for each device. You can use these attributes in segmentsA group of people who match a series of conditions. People enter and exit the segment automatically when they match or stop matching conditions. and other campaign workflow conditions to target the device owner, just like you would use a person’s other attributes. You cannot, however, use device attributes to personalize messages with liquidA syntax that supports variables, letting you personalize messages for your audience. For example, if you want to reference a person’s first name, you might use the variable {{customer.first_name}}. yet.

Along with these attributes, we automatically set a last_used timestamp for each device indicating when the device owner was last identified, and the last_status of a push notification you sent to the device. You can also set your own custom device attributes. You’ll see a person’s devices and each device’s attributes when you go to Journeys > People > Select a person, and click Devices.

device attributes on a person's profile
device attributes on a person's profile

 Your source shows device attributes in the context object

When you inspect calls from the SDK (the sourceA source is a website or server that you want to capture data from—it’s a source of data! in Data Pipelines), you’ll see device information in the context object. We flatten the device attributes that you send into your workspace/Journeys, so that they’re easier to use in segmentsA segment is a group of people in your audience that you want to target with campaigns, messages, etc. You can join groups of people manually, or by attribues and event data.. For example, context.network.cellular becomes network_cellular.

  • id string
    Required The device token.
    • _last_status string
      The delivery status of the last message sent to the device—sent, bounced, or suppressed. An empty string indicates that that the device hasn’t received a push yet.

      Accepted values:,bounced,sent,suppressed

    • app_version string
      The version of your app that a customer uses. You might target app versions to let people know when they need to update, or expose them to new features when they do.
    • cio_sdk_version string
      The version of the Customer.io SDK in the app.
    • device_locale string
      The four-letter IETF language code for the device. For example, en-MX (indicating an app in Spanish formatted for a user in Mexico) or es-ES (indicating an app in Spanish formatted for a user in Spain).
    • device_model string
      The model of the device a person uses.
    • device_os string
      The operating system, including the version, on the device.
    • network_bluetooth boolean
      If true, the device’s bluetooth connection is on.
    • network_cellular boolean
      If true, the device’s cellular connection is on.
    • network_wifi boolean
      If true, the device’s WiFi connection is on.
    • push_enabled string
      If "true", the device is opted-in and can receive push notifications.

      Accepted values:true,false

    • screen_height integer
      The height of the device’s screen in pixels.
    • screen_width integer
      The width of the device’s screen in pixels.
    • timezone string
      The timezone of the device.
    • Custom Device Attributes* string
      Custom properties that you want to associate with the device.
  • last_used integer  (unix timestamp)
    The timestamp when you last identified this device. If you don’t pass a timestamp when you add or update a device, we use the time of the request itself. Our SDKs identify a device when a person launches their app.
  • platform string
    Required The device/messaging platform.

    Accepted values:ios,android

Set custom device attributes

You can also set custom device attributes with the setDeviceAttributes method. You might do this to save app preferences, timezones, or other custom values specific to the device. Like profile attributes, you can pass nested JSON to device attributes.

However, before you set custom device attributes, consider whether the attribute is specific to the device or if it applies to the person broadly. If you want an attribute to persist beyond the life of the device token, you should apply it to the person rather than the device.

const setDeviceAttributes = () => {
    const deviceAttributes = {
        type : "primary_device",
        parentObject : {
            childProperty : "someValue",
        },
    };
    CustomerIO.setDeviceAttributes(deviceAttributes)
}

Manually add device to profile

In the standard flow, identifying a person automatically associates the token with the identified person in your workspace. If you need to manually add or update the device elsewhere in your code, call the method CustomerIO.registerDeviceToken(token).

const registerDevice = () => {
     // Customer.io expects a valid token to send push notifications
     // to the user.
     const token = 'token'

     CustomerIO.registerDeviceToken(token)
 }

Stop identifying a person

When a person logs out, or does something else to tell you that they no longer want to be tracked, you should stop identifying them.

Use clearIdentify() to stop identifying the previously identified person (if there was one).

CustomerIO.clearIdentify()

Identify a different person

If you want to identify a new person—like when someone switches profiles on a streaming app, etc—you can simply call identify() for the new person. The new person then becomes the currently-identified person, with whom all new information—messages, events, etc—is associated.

CustomerIO.identify( userId: "new.person@example.com", traits: {
    first_name: "New", 
    last_name: "Person"
}) 
Copied to clipboard!
  Contents
Current release
 2.0.0-beta.1
Is this page helpful?