For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.
Identify your users
Amplitude Academy
Tracking Unique Users with Amplitude
Learn how to track unique users with Amplitude.
Get startedAmplitude identifies users through three IDs. The SDK sends a device ID automatically, Amplitude computes an Amplitude ID that joins a person's devices into one profile, and you set the user ID when someone signs in.
Setting a user ID is optional but recommended, because it lets Amplitude connect events from every device a person uses. Set it after a user creates an account or logs in. Amplitude also attaches the anonymous events from before sign-in to that user ID, so you don't need to set one for anonymous users. If your product doesn't assign user IDs, skip this page.
For how Amplitude merges devices and profiles, refer to How Amplitude identifies unique users.
Best practices for setting user IDs
- Don't set the user ID if there isn't one. For example, if you set the user ID to the string
Nonefor multiple users, Amplitude doesn't recognize those users as separate users. Instead, Amplitude assumes all those users are the same user and groups all events for those users together under thatNoneuser ID. You can always set the user ID later. - Don't assign a user ID that might change. User IDs are fixed forever. For example, don't set a user's email address as their user ID, because email addresses change.
- User IDs are case-sensitive. If you set a user ID in a different case, Amplitude tracks two separate profiles for the same user.
- Assigning user IDs server-side can be tricky. If you encounter issues assigning user IDs, contact Amplitude Support.
- Reset when the user logs out. Otherwise, events from the next person on the same device attach to the previous user.
Set the user ID
Set the user ID after a user signs up or logs in. Replace USER_ID with a stable identifier from your own system, not an email address. To describe the user, send an Identify object, which sets user properties without sending an event.
amplitude.setUserId("USER_ID");
const identifyEvent = new amplitude.Identify();
identifyEvent.set("location", "LA");
amplitude.identify(identifyEvent);
For every Identify operation, refer to User properties in the Browser SDK documentation.
For other platforms, refer to the user ID section of your platform's SDK documentation.
Reset the user when they log out
In client-side SDKs, call reset when a user logs out. reset clears the user ID and generates a new device ID, so the next activity on that device appears to Amplitude as a new user.
amplitude.reset();
Was this helpful?