Sending Information into Drift

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

Sometimes you may find it useful to send Drift additional information about a visitor on your site. This additional information can help give your reps additional information about a visitor during a conversation or it can be used to create dynamic segments for campaigns or chat targeting.

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.

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 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.

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 seen before,- then we'll simply update that contact record in Drift.

drift.identify(XXX, { // XXX could be something like a GUID or other ID.
  email: 'abcd@example.com',
  nickname: 'John Doe',
  age: 21
})

// You should ensure that `drift.on('ready',...)` has been fired before calling identify - though typically timing isn't an issue if `identify` is called well after page load.

drift.api.setUserAttributes(attributes)

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() {
  drift.api.setUserAttributes({
    email: 'abcd@example.com',
    nickname: 'John Doe',
    age: 21
  })
})

`identify` vs. `setUserAttributes`

If you'd like to specify additional properties after the user has been identified, or if you want to set properties on the site visitor without necessarily knowing his or her email, use the drift.api.setUserAttributes() method instead

Want to pass in a specific value?

You aren't just limited to text and numbers! Find out about more data types here

drift.track

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'});
driftt.track('Shared Content', { contentId: 1, contentName: 'Proposal', contentType: 'document', method: 'Email' });

event
string

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

attributes
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

drift.page

Use drift.page to manually tell Drift that the page has changed so our targeting can adjust accordingly. This will send a page event to Driftt. 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.

drift.page('Main Content Page') // driftt.page(pageName)

// or

drift.page() // generic page event including both the url and title of the current page.

name
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

Sending Information into Drift


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.