{"_id":"560d769505b3941700338762","project":"560c93ad7e9b9d0d00ca81a2","version":{"_id":"560c93ae7e9b9d0d00ca81a5","project":"560c93ad7e9b9d0d00ca81a2","__v":9,"createdAt":"2015-10-01T02:00:14.709Z","releaseDate":"2015-10-01T02:00:14.709Z","categories":["560c93af7e9b9d0d00ca81a6","560c9d9399bb5a0d0044f220","560d76d899bb5a0d0044f307","560d76ee1ec45619006069ed","560d86e099bb5a0d0044f32e","560dba80373c0e0d0024ff3b","57c722ecdf19130e001fba5d","57c743d1b6f94a2200659903","58995ec083f743190077bbe2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"560c9d9399bb5a0d0044f220","pages":["560ca0517048021700e180e6","560d6190af9723190093812c","560d74751ec45619006069e9","560d769505b3941700338762"],"project":"560c93ad7e9b9d0d00ca81a2","version":"560c93ae7e9b9d0d00ca81a5","__v":4,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-10-01T02:42:27.154Z","from_sync":false,"order":0,"slug":"javascript-api-client-side","title":"JavaScript API (client-side)"},"githubsync":"","user":"560c92f2ac2859170013faa3","__v":1,"editedParams":true,"editedParams2":true,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-01T18:08:21.010Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"examples":{"codes":[{"name":"","code":"Attribution.track(event, [properties], [callback]);","language":"javascript"}]},"auth":"required","params":[{"_id":"560ca0517048021700e180e9","ref":"","in":"body","required":true,"desc":"The name of the event","default":"","type":"string","name":"event"},{"_id":"560ca0517048021700e180e8","ref":"","in":"body","required":false,"desc":"A hashtable of properties describing the event.","default":"","type":"object","name":"properties"},{"_id":"560ca0517048021700e180e7","ref":"","in":"body","required":false,"desc":"A callback function that gets called after a short timeout.","default":"","type":"object","name":"callback"}],"url":"/Attribution.track(event, [properties], [callback]);"},"isReference":true,"order":3,"body":"There are two main use cases for \"alias\" method:\n\n1) 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.\n\n2) 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).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.alias([userId], [previousId], [callback]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"**userId **\\n*String, required*\",\n    \"0-1\": \"The new User ID you want to associate the user with.\",\n    \"1-0\": \"**previousId **\\n*String, required*\",\n    \"1-1\": \"The previous ID that the user was recognized by.\",\n    \"2-1\": \"A callback function that gets called after a short timeout.\",\n    \"2-0\": \"**callback **\\n*Object, optional*\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.alias('00812938', '00812939');\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"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.","slug":"alias","type":"fn","title":"Alias"}

Alias

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.

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). [block:code] { "codes": [ { "code": "Attribution.alias([userId], [previousId], [callback]);", "language": "javascript" } ] } [/block] [block:parameters] { "data": { "0-0": "**userId **\n*String, required*", "0-1": "The new User ID you want to associate the user with.", "1-0": "**previousId **\n*String, required*", "1-1": "The previous ID that the user was recognized by.", "2-1": "A callback function that gets called after a short timeout.", "2-0": "**callback **\n*Object, optional*" }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "Attribution.alias('00812938', '00812939');", "language": "javascript" } ] } [/block]