On this page

Track unique users

Accurate unique user tracking helps Amplitude count users across anonymous browsing, sign-ins, and multiple devices. This article explains how Amplitude tracks unique users and how to keep user identity data consistent.

How Amplitude identifies unique users

Amplitude uses three IDs to track users: device ID, user ID, and Amplitude ID:

  • Device ID: For mobile applications, Amplitude pulls the Identifier for Vendors (IDFV) or generates a random alphanumeric string for the device ID. For web applications, Amplitude sets the device ID to a randomly generated Universally Unique Identifier (UUID) by default. The device ID persists unless a user clears browser cookies or browses in private mode.
  • User ID: You configure the user ID. Many products use a username or an internal unique identifier as the user ID. Use a stable value for the user ID. Don't assign anonymous users a user ID. Anonymous users still have Amplitude IDs and device IDs, so Amplitude might recognize them as the same user later.
  • Amplitude ID: After Amplitude receives a device ID, a user ID, or both, Amplitude generates the Amplitude ID and associates it with the collected identifiers. Amplitude needs only one identifier to generate an Amplitude ID. Amplitude prefers the user ID because multiple unique users could share the same device.

If Amplitude encounters a known device ID that is already tied to a user ID in a different project, Amplitude assumes the device ID is tied to that user ID in all projects, even if you don't have the Portfolio add-on. For more information, refer to Portfolios.

When multiple projects reside in a single organization, all projects must use the same variable as the user ID. Using the same user ID variable prevents tracking discrepancies. For example, if one project uses email addresses as user IDs and another project uses phone numbers, Amplitude doesn't merge those identifiers into the same Amplitude user profile. If you're on MTU billing, you might incur charges for multiple users.

Use advertising identifiers as the device ID

You can configure Amplitude to use the Identifier for Advertiser (IDFA for iOS) and the Advertising Identifier (AdID for Android) as the device ID. For more information, refer to the relevant SDK installation guide. Using advertising identifiers causes the device ID to persist across installs.

iOS users can reset the IDFA on their devices at any time. As of iOS 10, if a user limits ad tracking, iOS returns an IDFA of all zeros. Amplitude instead sets the device ID to either the IDFV or a randomly generated string.

Android users can reset the AdID on their devices at any time.

Set up cross-domain tracking

You can track anonymous behavior across two domains. For example:

  • Site 1: https://www.landingpage.com.
  • Site 2: https://www.productpage.com.

To track an anonymous user who starts on Site 1 and navigates to Site 2, pass the device ID from Site 1 as a parameter to Site 2. Then reinitialize the SDK with the passed device ID:

  1. From Site 1, get the device ID from amplitude.options.deviceId.
  2. Pass the device ID to Site 2 with a URL parameter or third-party cookie.
  3. Initialize the Amplitude SDK on Site 2 with amplitude.init('YOUR\_API\_KEY', null, {deviceId: '$DEVICE_ID'}).

How Amplitude assigns Amplitude IDs

The following scenarios show how Amplitude uses device IDs and user IDs to generate a new Amplitude ID or apply an existing Amplitude ID.

No user ID exists

If your product doesn't assign user IDs, Amplitude generates an Amplitude ID when Amplitude sees a particular device ID for the first time.

Device IDUser IDAmplitude ID
Anull1
Bnull2
Bnull2
Cnull3
Anull1
Cnull3

There are three unique users in this set.

The first event from each device gets a new Amplitude ID. Later events from the same device reuse the existing Amplitude ID. In this example, device A uses Amplitude ID 1, device B uses Amplitude ID 2, and device C uses Amplitude ID 3.

User ID follows anonymous events

If your product assigns user IDs, Amplitude assumes previous anonymous events on that device belong to a single user until Amplitude receives an event with a user ID. Amplitude then applies the same Amplitude ID to the anonymous events and the identified event.

Device IDUser IDAmplitude ID
Gnull4
Gnull4
GJohn4

There is one unique user in this set.

Amplitude logs the first two events anonymously on device G and assigns them Amplitude ID 4. The third event is the first event from device G that includes a user ID. Amplitude assigns John the same Amplitude ID as the anonymous events, so Amplitude counts one unique user.

Same user ID on multiple device IDs, with no anonymous events

Amplitude prioritizes user IDs over device IDs when assigning an Amplitude ID.

Device IDUser IDAmplitude ID
KZack5
LZack5

There is one unique user in this set.

User Zack sent an event on device K, and Amplitude assigned Amplitude ID 5. Whenever Zack's user ID appears again on any device, Amplitude assigns the event Amplitude ID 5, regardless of the device ID.

Multiple user IDs on the same device

If Amplitude receives an anonymous event after at least one user ID has appeared on that device, Amplitude assumes the last known user sent the anonymous event and assigns the event that user's Amplitude ID.

Device IDUser IDAmplitude ID
RJane6
Rnull6
RMary7
Rnull7
Rnull7

There are two unique users in this set.

Jane logs the first event on device R, and Amplitude assigns Amplitude ID 6. Amplitude receives the next event anonymously, for example after Jane logs out, but still assigns Amplitude ID 6 because Jane was the last known user.

Mary sends the third event on device R, and Amplitude assigns Amplitude ID 7. Amplitude receives the next two events anonymously and assigns them Amplitude ID 7. Amplitude assumes Mary sent those events because she was the last known user.

If you want to explicitly log users out or log events under an anonymous user, set the user ID to null and regenerate a new device ID. Follow the instructions in the iOS or Android SDK documentation.

Same user ID on multiple devices, with anonymous events

Device IDUser IDAmplitude ID
YDavid8
Znull9
ZDavid8
Znull8

David logs an event on device Y, and Amplitude assigns Amplitude ID 8.

Next, an anonymous user logs an event on device Z, and Amplitude assigns Amplitude ID 9 because no user is associated with the device.

Then David logs into the product on device Z. The sign-in event has Amplitude ID 8 because Amplitude ID 8 belongs to David.

Finally, Amplitude logs an event anonymously on device Z. The anonymous event receives Amplitude ID 8. David was the last known user, so Amplitude attributes the event to him.

In this scenario, the anonymous events on device Z have two different Amplitude IDs, even though only one user ID is associated with the device. Amplitude interprets Amplitude IDs 8 and 9 as a single user: David. When Amplitude detects the relationship between Amplitude IDs 8 and 9, Amplitude merges the IDs, so Amplitude counts only one user. The merge can only happen because the event with Amplitude ID 9 didn't have a user ID present.

If you're using Redshift, the data is immutable, and the anonymous event still has Amplitude ID 9 in the raw data. For more information, refer to Merged users.

Merged users

Merged users occur when Amplitude determines that an anonymous user, such as a user whose only ID is a device ID, is a recognized user with an Amplitude ID.

For example, a user gets a new device and logs events in your product anonymously before signing in. To Amplitude, these anonymous events look like they come from a new user, so Amplitude maps them to a new Amplitude ID.

When the user logs into their existing account, Amplitude maps all subsequent events to that user's existing Amplitude ID. The separate Amplitude IDs create two problems:

  • Amplitude counts the user twice in active and new user counts.
  • Amplitude doesn't attribute events received while the user was anonymous to the true Amplitude ID and the user's actual user ID.

Amplitude solves duplicate Amplitude IDs by cross-referencing the list of Amplitude IDs with an internal mapping of merged Amplitude IDs. Merged Amplitude IDs belong to the same user. Amplitude applies merged user mapping when you query on the dashboard. You can view a list of a user's merged IDs in their User Activity page, along with the merge times.

Important note

  • Amplitude can't merge user IDs. If you create a new user ID for an existing user, Amplitude recognizes them as different unique users.
  • Merged user mapping doesn't apply to raw data in Amazon Redshift, because the database contains raw event logs and not a merged users table. Without merged user mapping, Amplitude has observed an average change of about 5% in DAU numbers, with a higher-than-average change for web data.

Event IDs, device IDs, and merging users

After Amplitude merges users, the event ID count continues on a device-by-device basis:

Device IDUser IDAmplitude IDEvent ID
Anull81
ADavid82
ADavid83
Bnull91
BDavid82
BDavid83

If a user clears product data, for example by deleting and reinstalling the app, the event ID resets to 1. When a user deletes and reinstalls the app, Amplitude usually generates a new device ID as well, which then triggers a new merge.

After Amplitude merges users, a merged user might lose user property values that should stay unchanged, such as Start Version or initial UTM parameters, because the new user property values overwrite the original user property values. If merged users affect your user property values, contact Amplitude Support.

Was this helpful?