Skip to main content

Vue / Browser — Alias

Link an alias (e.g. anonymous ID) to the current user. Use this to merge anonymous events (from before login) with the identified user.

alias(alias)

Links an alias to the current user. Sends a $create_alias event. When to use: After login to merge anonymous events (from before login) with the identified user. This ensures all events are associated with the same user profile.

Vue example

Vanilla JS example

How it works

  1. Before login: User browses anonymously. Events are tracked with an anonymous ID.
  2. After login: Call identify(userId, traits) to set the user’s identity.
  3. Link alias: Call alias(anonymousId) to link the anonymous ID to the identified user.
  4. Result: All events (both anonymous and identified) are now associated with the same user profile.

See also