Skip to content

Creating or Updating user profile with Identify

The identify method is used to create or update a user profile in CustomerLabs. With identify method, you can update the user traits of a user in CustomerLabs.

It is a reserved method that triggers event called Create user.

properties = {
// customProperties object
};
_cl.identify(properties)

Before jumping to identify method, let’s understand what are External IDs.

An External ID is any identifier that is not natively generated by CustomerLabs but is used to recognize a user or group in another platform.

Examples:

  • Email address stored in your CRM → identify_by_email
  • Facebook FBP cookie → facebook__fbp
  • Your internal customer ID → crm_user_id
  • Shopify cart token → shopify_cart_token

When the same external ID appears across multiple events, CustomerLabs merges them into a single unified profile, improving match quality when syncing to ad platforms like Meta and Google Ads.

User External IDs are stored under the external_ids object inside customProperties.

KeyDescription
customerlabs_user_idCustomerLabs anonymous user ID
identify_by_emailUser’s email address
identify_by_phoneUser’s phone number
shopify_cart_tokenShopify cart token
facebook__fbpFacebook Browser Pixel cookie
google_analytics__client_idGA4 client ID
facebook_lead_idFacebook Instant Form lead ID
var customProperties = {
"external_ids": {
"<external_id_key>": {
"t": "string",
"v": "<value>"
}
}
};

To trigger the identify method, user_traits object and identify_by with ib: true attribute must be added to the customProperties object. external_ids object can also be added (but not mandatory) to the customProperties object.

properties = {
customProperties : {
user_traits : {
// traits
},
external_ids : {
// external ids
},
<identifier> : {
// trait used for identify by
"ib" : true
}
}
};
_cl.identify(properties)

The below keys are reserved for user traits in CustomerLabs.

  • First Name: first_name
  • Last Name: last_name
  • Email: email
  • Phone: phone
  • Address line 1: address1
  • Address line 2: address2
  • City: city
  • State/Province: state
  • Country: country
  • Country Code: country_code
  • Postal Code: zip
  • CustomerLabs User ID: customerlabs_user_id
  • Shopify Cart Token: shopify_cart_token


identify_by object (flagged with ib: true) that helps the system search for the user based on a specific property key to which ib is set to true and assign user traits to that user.

  • There should only be one identifier that ib is associated with per identify method call.
  • The identifier with ib should be also added under customProperties.
  • The value of ib should be set to true for the identifier when it is added to customProperties.

Reserved Identify By keys are,

  • Identify by Email: identify_by_email
  • Identify by Phone: identify_by_phone
  • CustomerLabs User ID: customerlabs_user_id
  • All the reserved user_traits and external_ids keys can be used as identify by.
var email = "johndoe@example.com";
var properties = {
"customProperties": {
"user_traits": {
"t": "Object",
"v": {
"first_name": { "t": "string", "v": "John" },
"last_name": { "t": "string", "v": "Doe" },
"phone": { "t": "number", "v": "1234567890" },
"email": { "t": "string", "v": email }
}
},
"external_ids": {
"identify_by_phone": {
"t": "string",
"v": "1234567890"
}
},
"identify_by_email": {
"t": "string",
"v": email,
"ib": true // The system will identify the user by this email
}
}
};
_cl.identify(properties);

When either email or phone or both may be available, use conditional logic to set the primary ib correctly.

// sample variables
var email = "johndoe@example.com";
var phone = "123456789";
// identify_by
var customProperties = {
"user_traits": {
"first_name": {
"t": "string",
"v": "John"
},
"last_name": {
"t": "string",
"v": "Doe"
},
"email": {
"t": "string",
"v": email
},
"phone": {
"t": "string",
"v": phone
}
}
}
if (email && email !== "") {
customProperties["identify_by_email"] = {
"t": "string",
"v": email,
"ib": true
};
if (phone && phone !== "") {
customProperties["external_ids"] = {
"t": "Object",
"v": {
"identify_by_phone": {
"t": "string",
"v": phone
}
}
};
}
}
else if (phone && phone !== "") {
customProperties["identify_by_phone"] = {
"t": "string",
"v": phone,
"ib": true
};
}
if (email || phone) {
_cl.identify(customProperties);
}

The “Update user” event is used to update the details (user_traits) of a user during a particular session. This is useful for multi-step forms where you collect information gradually.

To trigger an update of user traits across your workflow, you can send the event name as Update user.

_cl.identify("Update user", properties)
var properties = {
"customProperties": {
"user_traits": {
"t": "Object",
"v": {
"first_name": { "t": "string", "v": "John" },
"last_name": { "t": "string", "v": "Doe" },
"phone": { "t": "number", "v": "123456789" },
"email": { "t": "string", "v": "johndoe@example.com" }
}
},
"identify_by_email": {
"t": "string",
"v": "johndoe@example.com"
}
}
};
_cl.identify("Update user", properties);