The alias
call lets you merge different identities of a known user.
alias
events only to select downstream destinations. Refer to the destination-specific documentation for more details.alias
call is used only for merging user identitites. It does not update the user's traits
or other common properties.alias
fields
In addition to the Common Fields, the alias
call accepts the following fields:
Field | Description | Data type | Presence |
---|---|---|---|
userId | The user's unique identifier in the database. Either userId or anonymousId should be present. | String | Optional, if anonymousId is already set. |
previousId | The user's previous identifier. | String | Required |
userId
vs previousId
- The
previousId
attribute refers to the previous user identifier. It could be either:- An
anonymousId
assigned to the user (by the browser if the user is a new visitor or has not logged in yet, or the session ID if you're using a server-side SDK). - A previously set
userId
to identify the user via theidentify
call.
- An
- The
userId
is the user's new identity or an existing identity that you want to merge withpreviousId
.
Sample payload
A sample payload of an alias
call is shown below:
{ "type": "alias", "previousId": "name@surname.com", "userId": "12345"}
The corresponding event that generates the above payload via the JavaScript SDK is as shown:
rudderanalytics.alias("12345")
anonymousId
as previousId
in the payload.alias
call must be made from the client-side as the anonymousId
is generated via the browser. Similarly, if you're using a server-side SDK, the alias
call must be made from the server-side as the session ID is set as the anonymousId
.Contact us
For more information on the topics covered on this page, email us or start a conversation in our Slack community.