Installation and User Identification

The Javascript SDK is an easy way to install Drift, while also identifying users and tracking events if you’re installing it in your app.

Not yet using Drift?

Sign up here!


If you’re still creating your account, copy and paste the code snippet inside your webpage’s, or web app’s, <head> block. If you already have account, get the Drift code at the bottom left of this page.

To make life easy for you, this JS snippet will never change… after installing this you’ll never have to touch it again no matter how many new features we release.

Example Approach

Using Wordpress, Shopify, Segment, or Google Tag Manager?

You can easily install Drift with any of these platforms. Connect Drift to your service in app or see this helpdoc for Google Tag Manager.

Many other Content Management Platforms can also be supported by adding a Javascript content element and pasting the Drift snippet in. We recommend inserting the snippet into the <head> block of your page if possible. If the Drift widget appears and is functional, you're good to go.

Using the Python Django framework?

We have a Python package for Django that can assist with installation:

Using ReactJS?

We have a community provided react-component that can be used:

This can provide a convenient wrapper around the drift javascript code, which is typically stored in a static <script> block in normal html.

Using Server Side Rendering with React?

Server side rendering can often break client side libraries if not handled carefully, here's an approach for handling this with the Drift widget. See:

You're all set!

Want Drift in your application or product? Let's identify your users!

Drift uses cookies to identify site visitors who return to your website so we can maintain their identify. This means that if the end user clears their cookies or goes to a different device, we'll lose the connection to the previous history.

But if people are already logged into your application, then you know exactly who they are!

When you know the identity of who is on the website, you can explicitly tell Drift which user this is. This way, no matter which device or browser they're using Drift will treat them the same.

You can do this with a single line JavaScript. All you need to know is the unique user ID that your platform uses toidentify whoever is on your website.

This ID might be numerical, or an email address, or a random string of characters.

Here's a code example

In this example, the userId is USER-142

<!-- html webpage -->

Know more information about this person?

You can pass this information in as the second argument to the drift.identify function, and we can use this information in the Drift platform.

<!-- html webpage -->
drift.identify('USER-142', {
  email: '',
  numberOfLogins: 5,
  phone_number: '222-3333-4444'


The unique user ID in your company’s user table for the user.


A dictionary of attributes you know about this user, such as their email, name, company.
Note: the attributes object must be a flat object.
See this doc about different data types you can use

Removing Identification when your users log out

When your users are done using your services and log-out of your application, it's important to clear Drift's memory of this user so the next person using the computer doesn't see any previous history.

In order to do this, just use drift.reset() to completely clear Drift's tracking cookies. To Drift, this is a brand new person now.