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)

If you're already identifying users on your website with a unique identifier from your own system (e.g. if they are logged in) you can use the drift.identify() method to pass additional contact properties for that user.

drift.identify(userId, {
  email: 'abcd@example.com',
  nickname: 'John Doe',
  age: 21
})

Note:

Generally you should only call drift.identify() once per page view. If you'd like to specify additional properties after the user has been identified, use the drift.api.setUserAttributes() method instead.

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
  })
})

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