Sending Information into Drift

Sometimes you may find it useful to send Drift additional information about a visitor on your site. This information is commonly represented as attributes on the contact record and can help give your sales and support teams additional context about a visitor during a conversation

These attributes can also be used to create dynamic segments for campaigns or chat targeting.


Create your attributes first

We recommend setting up your custom attributes first before using the below methods.

For further info, see the following page:

drift.identify(userId, attributes)

The most common use case for identify is to externally sync the identity of a contact or site visitor currently on your website with Drift.


Use caution leveraging drift.identify

An improper implementation of this function can lead to site visitors being able to see the chat history of each other if you're issuing non-unique external identifiers. Signed identities ( is REQUIRED for any use of drift.identify where visitor privacy and personal information are a consideration.

If you're already tracking users on your website with a unique identifier from your own system (i.e. a user id for an email in response to a log in event) you can use the **drift.identify()** method to pass this information along with additional contact properties for that user. If you wish to use identify, we recommend using this method with a unique and consistent, email/userId pair for a given user. Please note that properties are case-sensitive.

identify will create a new contact record in your account if the ID has not been seen before - email is not a unique identifier in drift. If the id has been seen before,- then we'll simply update that contact record in Drift.

yourapp.login(...).then(yourUserObject => {
  drift.identify(, { // assuming your DB identifier could be something like a GUID or other unique ID.
    age: yourUserObject.age,
    // ...              

// Your user object may have different fields that you want to pass into drift. You can add those here as well.


How to Use The Method - Placement

drift.identify should be called prior to drift.load on a given page. This is because, by design, Drift will tie a site visitor with a contact as soon as load is called - generally this is an anonymous contact (not stored / indexable until identified) unless some identity is established prior to load (via cookie, integration with specific platforms, or via the drift.identify method). Calling identify prior to load establishes proper auth and identity of the user for use in chat experiences upon the loading of Drift.


If you're not identifying users, or if want to pass contact properties without worrying about the user's identity, you can use the **drift.api.setUserAttributes(**) method instead. You'll need to wait for the `ready` event before the API is ready to be called.

drift.on('ready', function() {
    email: '[email protected]',
    nickname: 'John Doe',
    age: 21


A warning on assigning attributes

Attributes will automatically be created if they haven't been declared.

For example, if you call setUserAttributes({"my_custom_property": 123}) and my_custom_property hasn't been previously created in Drift, we will automatically create and infer the type of the attribute (in this case numeric).

We recommend creating the attributes beforehand in Drift that you intend to use:

If you're trying to update Drift's default attributes programmatically, make sure you're passing in your values in the proper format. For instance, if you're sending a UTM value to *recent_source programmatically, you may need to stringify your value.

Ex: recent_source: String(new URLSearchParams('utm_source')),


identify vs. setUserAttributes

We recommend using identify over setUserAttributes when you want to use your own custom ID values for contacts created in Drift.

setUserAttributes is useful to specify custom properties after the user has been identified, or if you want to set attributes on the site visitor before knowing their email.

Please note though, that setUserAttributes relies on the presence of an identifying cookie, or the use of drift.identify in order to update an existing Drift contact record. setUserAttributes will create a new contact record in Drift if the site visitor is anonymous and may lead to duplicate contact records within Drift.

You aren't just limited to text and numbers for attributes! Find out about Drift data types here! Attributes should be treated as case-sensitive.


Did the site visitor view some content? Enroll in a new course or product on your website? Send these one-time events into Drift and we can use this information inside of our messaging.

drift.track('enrolled in service', {
  firstTime: false,
  newService: true

// or

drift.track('Exported', {exportedObject:'2015_users'});
drift.track('Shared Content', { contentId: 1, contentName: 'Proposal', contentType: 'document', method: 'Email' });

Once your have tracked a site visitor we can access this Segment by:

  1. Go to Visitors > Contact Segments > New Segment > Click on 'New segment'
  2. On the 'Choose a stream event' panel we can click on 'Filter by'
  3. Select the fourth option 'Raw Events'
  4. Under Events you should have 'nameOfEvent'
  5. Then you can select some operator functionality. Hit APPLY when done.
  6. Once we have the segment created. Then we can add to existing playbooks or create a new playbook for this segment.
This is the name of the type of event. You should try to reuse the same events with different properties to describe similar actions such as Share or Link Clicked
object, optional
A dictionary of attributes about this type of event, such as shareType or linkUrl.
Note: the attributes object must be a flat object. Nested objects or arrays will not work

Use **** to manually tell Drift that the page has changed so our targeting can adjust accordingly. This will send a page event to Drift. It takes an optional pageName and then sends info about the current page that the user is on such as the url and title.

This could also be applied for updating the page label on single page apps where the browser page url behaves differently.'Main Content Page') //

// or // generic page event including both the url and title of the current page.
string, optional
This is the name that you want to be able to easily be able to identify this call by, it will get stored in a track event under the attribute pageName


Drift Privacy Policy

Drift respects privacy rights and data protection laws. You may only share other people's personal information with Drift, whether directly or through third-party integrations, if you are permitted to do so under applicable law. Drift Privacy Policy