FS.identify - Identifying users

Each time a page loads from a user you can identify, you'll want a bit of JavaScript to call the FS.identify function to associate your own application-specific id with the active user. In this article, we'll refer to this as the uid (unique user id). 

FS.identify(uid); // uid is a string containing your app's user id for the current user

FullStory maintains user identity using cookies, which can change over time and across devices. FS.identify allows FullStory to associate the current cookie with the user as your application uniquely knows her. We use the term uid to refer to your app's id for a given user.  

You should not use FS.identify for anonymous or guest users, since you don't actually know who they are. Careful! You can't re-identify someone once you've given them a unique id. Not using it on the logout page can also help keep different users sharing a browser from being mixed up.

The uid is opaque to FullStory, although it is a useful search criterion.

Example uids

Suppose you use integers as unique keys for users in your application database. Identify a user to FullStory like so:

FS.identify('462718483'); // 462718483 appears in your app database as this user's id

Or perhaps your app distinguishes users by email address:

FS.identify('daniel.falko@example.com');


Specifying display name and email

FS.identify also accepts an optional second argument: a JSON object containing simple key/value pairs that you'd like to record for the current user.

FS.identify(uid, userVars); // userVars is a JSON dictionary

Kindly supply values for the special system fields displayName and email like this:

FS.identify('462718483', {
 displayName: 'Daniel Falko',
 email: 'daniel.falko@example.com'
});

Display names and email addresses will show up automatically the next time you browse your user list in FullStory.

You don't have to specify both display name and email as in the above example; either one is fine.

userVars can specify fields other than displayName and email. In fact, you can record any custom fields you like so long as you follow the naming rules. For more about custom fields, see FS.setUserVars.

The userVars argument to FS.identify is the same format expected by FS.setUserVars. It's more convenient to write FS.identify(uid, userVars) instead of FS.identify(uid) immediately followed by FS.setUserVars(userVars). The two formulations are equivalent, though.


Special Considerations

We have found that there are a handful of uids that can be easily misused. Usually this manifests itself in someone trying to apply a uid when they do not actually know who a particular user is.  As a result, FullStory will ignore some special values as invalid, including: 0, 1, -1, "nan", "n/a", "undefined", "null", and "nil". You should not use these values as uids for specific users since we'll automatically ignore them. Instead, try to find a different scheme or reserve those identifiers from being applied.

Once a user has been identified with a uid, you cannot change that association. For example, it is not okay for user 5673 to also be user 9816, or to also have bob@bobsworld.org as a uid. It is perfectly fine for the user with uid 5673 to have an email address of bob@bobsworld.org, because that is User 5673's email, not their unique uid.

Anonymizing Users

If you wish to make a previously-identified user anonymous (such as during logout), you can call FS.identify(false). This will automatically split the session and associate the new session with a new anonymous user.

Impersonating Users

When you're impersonating (e.g., when your app's admin system allows support agents to log in as) a user, we recommend you differentiate the unique ids passed to FS.identify()to disambiguate impersonated users from "real" users. 

If you normally call:

FS.identify('name@customer.com');

you would instead call:

FS.identify('support@app.com::name@customer.com');

You can also differentiate the displayName variable to render it more cleanly. We use the following to make this look nicer in the UI:

{displayName:'someone@fullstory.com as name@customer.com'}


Can’t find what you’re looking for?

The FullStory team awaits your every question.

Contact Us