alias is used to merge two user identities, effectively connecting two sets of user data as one. It is an advanced method and is not necessary for most integrations.

❗️

Warning!

  • The JavaScript API (Client-Side) articles are intended for developers!
  • Attribution should be installed by a developer.
  • Attribution CANNOT be installed ONLY with Google Tag Manager.
  • Do not minify or bundle Attribution snippet inside a webpack or it may render unstable in some conditions.
  • Please try to avoid putting snippet inside a JS closure. You are still free to call alias() from inside your JS app using window.Attribution variable.

There are two main use cases for "alias" method:

  1. used to when you really want to merge two use data into one, this could be if your user moved/created new account (for example due to technical issues) but you still want to see the whole hist history as one user.

  2. you are doing "identify" call only on server-side. In this case would need previousId parameter to be Anonymous ID which you can access from JS snippet by calling Attribution.user().anonymousId(); (this method is not recommended unless you have specific needs and understand what you are doing).

Attribution.alias([userId], [previousId], [callback]);
Parameter (type)Description
userId
String, required
The new User ID you want to associate the user with.
previousId
String, required
The previous ID that the user was recognized by.
callback
Object, optional
A callback function that gets called after a short timeout.
Attribution.alias('00812938', '00812939');