Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Identity Resolution ExternalIDs


FREE x
TEAM x
BUSINESS
ADDON
(information)

The steps in this guide pertain to spaces created before September 27th, 2020

For spaces created after September 27th, 2020, please refer to the Identity onboarding guide.


Default externalIDs

default-externalids page anchor

The Identity Graph creates or merges profiles based on externalIDs. ExternalIDs will become the identities attached to a user profile in the Profile explorer.

(success)

Success!

Navigate to Unify > Profile explorer to view identities attached to a profile, along with custom traits, event history, and more.

Example of external identities in the Profile explorer.

Segment automatically promotes the following traits and IDs in track and identify calls to externalIDs:

External ID TypeMessage Location in Track or Identify Call
user_iduserId
emailtraits.email, context.traits.email or properties.email
android.idcontext.device.id when context.device.type = 'android'
android.idfacontext.device.advertisingId when context.device.type = 'android' AND context.device.adTrackingEnabled = true
android.push_tokencontext.device.token when context.device.type = 'android'
anonymous_idanonymousId
ga_client_idcontext.integrations['Google Analytics'].clientId when explicitly captured by users
ios.idcontext.device.id when context.device.type = 'ios'
ios.idfacontext.device.advertisingId when context.device.type = 'ios'
ios.push_tokencontext.device.token when context.device.type = 'ios'
(information)

Info

The Google clientID (ga_clientid) is a unique value created for each browser-device pair and will exist for 2 years if the cookie is not cleared. The analytics.reset() call should be triggered from Segment end when the user logs off. This call will clear the cookies and local Storage created by Segment. It doesn't clear data from other integrated tools. So on the next login, the user will be assigned with a new unique anonymous_id, but the same ga_clientid will remain if this cookie is not cleared. Hence, the profiles with different anonymous_id but with same ga_clientid will get merged.


Unify resolves identity for any other externalIDs that you bind to users - such as a phone number or any custom identifier that you support.

As long as you've configured custom externalIDs, such as phone, in your Space's Identity Resolution rules, you can include it with the context.externalIds array, the properties object, or the context.traits object.

As seen in the example below, you can send custom externalIds in the context object of any call to Segment's API.

The four fields below (id, type, collection, encoding) are all required:

KeyValue
idvalue of the externalID
typename of externalID type (app_id, ecommerce_id, shopify_id, and more)
collectionusers if a user-level identifier or accounts if a group-level identifier
encodingnone

As an example:

1
analytics.track('Subscription Upgraded', {
2
plan: 'Pro',
3
mrr: 99.99
4
}, {
5
externalIds: [
6
{
7
id: '123-456-7890',
8
type: 'phone',
9
collection: 'users',
10
encoding: 'none'
11
}
12
]
13
})

Additionally, adding phone with the properties object gets picked up by Unify and applied as an externalID:

analytics.track('Subscription Upgraded', { plan: 'Pro', mrr: 99.99, phone: '123-456-7890'})

You can also include phone using the context.traits object and Unify adds it as an externalID to the profile.

analytics.track('Subscription Upgraded', { plan: 'Pro', mrr: 99.99}, {traits : {phone_number: '123-456-7890'}})

Unify creates a user (user_id: use_123) with the custom externalID (phone: 123-456-7890). Query the user's phone record by using the externalID (phone: 123-456-7890), or update the profile with that externalID going forward. (Note: externalIDs must be lower-case.)


Viewing promoted externalIDs

viewing-promoted-externalids page anchor

Users can view which externalIDs are promoted on each event by viewing the raw payload on Events in the User Profile in the "external_ids" object.

For example, the following user had anonymous_id and user_id promoted as identifiers from the Course Clicked track call:

An example raw payload for an Event in the User Profile.

For example, a new anonymous user visits your Pricing page:

1
analytics.page('Pricing', {
2
anonymousId: 'anon_123'
3
title: 'Acme Pricing',
4
url: 'https://acme.com/pricing',
5
referrer: 'https://google.com/'
6
});

At this point, the Identity Graph will create a new user with external id (anonymous_id: anon_123) and a persistent and globally unique segment_id, in this case: use_4paotyretuj4Ta2bEYQ0vKOq1e7.

An anonymous user associated to an external id in the Identity Graph.

Any new events received with the same external id (anonymous_id: anon_123) are appended to same user use_4paotyretuj4Ta2bEYQ0vKOq1e7.

Next, the user goes to a sign up form and signs up:

1
analytics.track('User Signup', {
2
userId: 'use_123',
3
anonymousId: 'anon_123'
4
});

At this point, the Identity Graph associates external ID (user_id: use_123) with the same user use_4paotyretuj4Ta2bEYQ0vKOq1e7.

Identities associated to a user in the Identity Graph.