Skip to main content
In order to merge behavioral and preferential data to create AI digital twins of your customers, Rehearsals needs to identify individual users. This is the most guaranteed way to build accurate customer profiles and get a complete picture of how they’re using your product across different sessions, devices, and platforms.
While Rehearsals can also extract user information through visual events (automatically detecting emails and names in your UI), programmatically identifying users is the most efficient and consistent method.

Quick Start

After a user logs in or signs up, call identify() to link their sessions to their user profile
We also allow custom parameters to be injected with {} . By default, we allow an identifier, email and fullName, to add additional properties see NEW SECTION, the code you write would look like this:
When a user logs out, call reset() to start a fresh anonymous session:

How identify() Works

When a user visits your website, Rehearsals automatically assigns them an anonymous session, which is stored locally. This enables us to track anonymous users even across different page visits. By calling identify() with a unique user ID from your system (usually from your database), you link all of that user’s sessions together. This enables you to:
  • Track a user’s behavior across multiple sessions
  • See what they did before they logged in for the first time
  • Associate their activity across different devices
  • Build comprehensive user profiles with behavioral insights

Viewing Identified Users

To see your identified users, log into the Rehearsals Dashboard, go to the Data folder in the sidebar, and click on Users.

API Reference

rehearsals.identify(userId, properties)

Links a user to the current session.

Parameters

  • userId (string, required) - Your unique user identifier. This should be:
    • An email (recommended)
    • A string that uniquely identifies the user in your system
    • Typically a database ID, UUID, or similar
    • Must be unique per user - two users should never have the same ID
  • properties (object, optional) - Additional user information:
    • email (string) - The user’s email address
    • fullName (string) - The user’s full name
    • customAttribute (string | int | boolean) - See our documentation to add any custom attribute

Returns

A Promise that resolves when the user is successfully identified. You typically don’t need to await this - it runs in the background without blocking your page.

Examples

rehearsals.reset()

Ends the current session and starts a new anonymous session. Call this when a user logs out to ensure their sessions are properly separated.

Returns

A Promise that resolves when the session has been reset.

Example

Best Practices

1. Call identify() as soon as the user is authenticated

Call identify() immediately after a user logs in or when your app loads if the user is already authenticated:
You only need to call identify() once per session. If you call it multiple times with the same data, subsequent calls will update the user information if needed but won’t create duplicates.

2. Use unique strings for user IDs

Critical: If two users have the same user ID, their data will be merged and they will be considered one user in Rehearsals. Good examples:
Bad examples - DO NOT USE:
Rehearsals has built-in protections to prevent the most common user ID mistakes.

3. Always call reset() on logout

When a user logs out, call reset() to unlink future sessions from that user. This is especially important if users might share a computer.
We strongly recommend calling reset() on logout even if you don’t expect users to share computers. This ensures clean data separation between users.

4. Page navigation - no need to call again

You do not need to call identify() on every page load or navigation. Once you’ve identified a user in a session, they remain identified until:
  • They log out (and you call reset())
  • They clear their browser data
Note: session expiration will attribute a new session to the previously identified user unless reset

Common Use Cases

User Login

User Signup

User Logout

Check if User is Logged In on Page Load

Custom Attributes

You can create custom attributes that will apear and be filterable in your sessions table by leveraging our Identify() API. To get started, head to the sessions table and hit the + in the top right header of the table, and hit Programmatic API :
Custom attribute creation form
Click the plus button and select Programmatic API
This allows you to create:
  • a name that will display in your sessions table and be filterable
  • a machine_readable_name that you can customize and is what you will use if passing in a custom property to the Identify API’s optional {} param. So if you add a custom number attribute with the machine readable name: exampleCustomAttribute, you would call the api with:

Framework-Specific Examples

React

Vue.js

Next.js

Vanilla JavaScript

Troubleshooting

Having issues with user identification?

Identify Users Troubleshooting

Get help with common identification issues including users not being linked, merge problems, and session reset issues