Getting started with clearbit.js
Clearbit.js is a client-side javascript library makes it easy to send data from your website to Clearbit. With this library, you can send page views and pertinent custom person or company traits to Clearbit, which is used for Clearbit X.

Add the clearbit.js snippet to your website html

Head to the Clearbit.js configuration page to copy and paste the javascript snippet into the <head> element of your website.
Next, add any domains that you'll be loading Clearbit tags on to the Allowed Referrers list. This is a security measure that will ensure your public API key won't be used on any other sites.
If you just want to send your web traffic to Clearbit X, you're all done! Visit your Clearbit Companies Dashboard to see your live web traffic.

If you want to be more precise about which known people (as opposed to which companies) are on your site at a given time, as well as to be able to create people segments and destinations, you'll want to identify your users.

Identify your users

Identifying users allows clearbit.js to associate custom user traits to page view events and Clearbit X to create people segments. Note that clearbit.js uses cookies to save all of this data to the session.

The `identify` method is how you associate your users, their page views, to a recognizable `user_id` and `email`.

Here is the `identify` method definition:

clearbit.identify([userId], [traits]);

The `identify` call has the following fields:
string, optional
This is the unique and immutable ID for the user. An example would be an ID generated by a database or a UUID.
object, optional
A dictionary of traits you know about the user, like their `email` or `company_domain`. This is what will be associated with all events. Learn more in the traits reference.
Here's an example of a basic `identify` call:

clearbit.identify("77e21cfd-2198-4000-944c-529097fc7019", {
  email: ""

Wait a moment! When you copy and paste the above code on your site, you’ll need to replace all those hard-coded strings with details about the currently logged-in user.

We suggest using a backend template to inject an `identify` call into the footer of every page of your site where the user is logged in. That way, no matter which page they're on, they will be identified.

Depending on your templating language, it might look something like this:

clearbit.identify('{{ }}', {
  email: '{{ }}'

The traits is a dictionary of values that is associated with the user and subsequent page view events.

Note that traits can be totally customizable. However, there are specific traits that Clearbit treats a bit differently.
string, optional
This is just the email of the user. An example would be "".
string, optional
The domain of the company. Clearbit uses this trait to associate the user with their company. An example would be "".