Identify is used to link a users actions and pageviews to a recognizable name or email address.

❗️

Warning!

  • The JavaScript API (Client-Side) articles are intended for developers!
  • Attribution should be installed by a developer.
  • Attribution CANNOT be installed ONLY with Google Tag Manager.
  • Do not minify or bundle Attribution snippet inside a webpack or it may render unstable in some conditions.
  • Please try to avoid putting snippet inside a JS closure. You are still free to call identify() from inside your JS app using window.Attribution variable.

We recommend using the userId field from your database and passing the email address in as a trait in case a user changes their email address later on. You can pass us as many customer traits as you’d like to save.

Attribution.identify([userId], [traits], [callback]);

When calling Identify() the userId pass should be the universal userid used in your database.

If you do not have a universal userid to pass here you can omit 'userid' and identify() customers with traits like name & email.

Parameter (type)

Description

userId
String, optional

The ID used to identify this user in your database. You can omit this and just record traits if you don’t yet have a database ID.

traits
Object, optional

A hashtable of traits describing the user such as name and email.

callback
Object, optional

A callback function that gets called after a short timeout.

Attribution.identify('YOUR_USER_ID', { email: '[email protected]' });

*The identify call should be used whenever a visitor identifies themselves by filling out a form, signing up, or signing in.

Special Properties for Identify

Attribution app recognizes special properties on the identify call, and displays them on the customer view in the app. Here’s are the special properties and an example of an call with all of them:

Trait (type)

Description

email
String

The user’s email address.

firstName
String

The user’s first name

lastName
String

The user’s last name.

name
String

The user’s full name.

createdAt
Date

The date the users account was first created. Must be in ISO 8601 time format.

companyId
String

If user belongs to company inside your internal data structure you can specify it unique ID of that company. This allows to enable Account Based Marketing (ABM) feature.

companyName
String

If user belongs to company you can specify full company name here.

If you want to distinguish between new and existing customers in Attribution app you must add the createdAt date only once when a new user registers . createdAt is expected to be date time (JavaScript date or ISO 8601 time format).

Attribution.identify('YOUR_USER_ID', { 
  email: '[email protected]',
  firstName: 'Bob',
  id: '00812938', // Note: redundent, just here as example
  lastName: 'Slydell',
  name: 'Bob Slydell',
  createdAt: new Date() // Note: Only do this once or specify exact datetime
});

Finally it is imperative that you place the Attribution.identify() code after the Attribution app snippet so the call can be properly defined prior to loading.

Calling Identify() on an oAuth page

If your team uses some sort of oAuth integration like, sign in/up with Google, Facebook, Twitch etc. you should follow the steps below for identifying visitors.

  1. The visitor visits your site A
  2. They click to log in with a oAuth connector and are redirected to site B
  3. After a successful oAuth they are sent back to to site A
  4. You should then call Identify() on site A.

Using Identify() with jQuery

If you plan to call identify() with jQuery please be sure to load jQuery prior to calling identify(), example below:

<script type='text/javascript'>
jQuery(document).ready(function() {
 $( ".hs-form" ).submit(function( event ) {
   Attribution.identify({
     email: $(".hs-form input[name=email]").val()
   });
   event.preventDefault();
 });
});
</script>