Important: As of August 13, 2024, this page will no longer be actively maintained. Please refer to the current version of this content here.
Analytics supports aliasing between anonymous IDs and user IDs to allow customers to unify event streams submitted with separate unique keys.
Aliasing is typically used to connect the activity stream of an anonymous user to their known activity stream after they have been identified as a known user.
For example, when a user first visits your website, either they are assigned an anonymous ID by the Analytics client or you can set an anonymous ID yourself. After the user signs up, logs in, or otherwise identifies themselves, their activity should now be recorded under a known user ID. Aliasing the two IDs together ensures a seamless activity stream in Analytics under one unique user ID vs two unique user IDs.
An aliasing API call consists of three components: an anonymous ID, a user ID, and your API key. An anonymous ID is an ID used to identify a user before they’ve registered, logged in, or otherwise identified themselves. A user ID is the ID used to uniquely identify a single user within your application – this should probably be an immutable field that’s tied to the user table in your database.
After receiving an alias call, all data submitted in the future from either the anonymous ID or a user ID will be processed as coming from the same user. Alias calls can be done retroactively for all self-service integrations.
As a best practice, we recommend that an alias call between a pair of IDs is made exactly once. It’s sensible to make this call the first time a user identifies themselves, such as upon registration within your application.
Note that improper use of aliasing can cause irreparable damage to data. Alias calls are permanent, and cannot be undone.
- An anonymous ID can be aliased to only one user ID (there is a many-to-one relationship between anonymous IDs and User IDs)
- You cannot alias a user ID to another user ID
- You cannot “chain” alias calls with multiple user IDs (i.e. Anon1 -> User1 -> User2 is invalid)
- Alias calls are done retroactively on a nightly basis for all self-serve integrations
Javascript Method Calls
Indicative.sendAlias()
The Analytics client automatically generates a default unique ID (a UUID) to use on all events until `Indicative.setUniqueID(id)` is called. At that point, `Indicative.sendAlias()` can be called to alias the UUID to the ‘id’ parameter set within `Indicative.setUniqueID(id)`
Indicative.setUniqueID(id, true)
This will automatically call `Indicative.sendAlias()` after setting the new unique ID. If you just callIndicative.setUniqueID(id)` (without ‘true’) it will not send the alias call.