setUserId
The setUserId() method sets the user ID for a specific user. It can be the same identifier as in your CMS, CRM or sales system. The user ID helps to recognize the user across devices.
Syntax
getTracker().setUserId("userId");
tracker.userId = "userId"
Parameters
userId (string, required)
A non-empty, unique identifier of the user. Example: customer ID. It needs to be unique for each user. Can be up to 1024 bytes (1024 ASCII characters).
Examples
To set a user ID as ABC123
and send it with a screen view:
getTracker().setUserId("ABC123");
TrackHelper.track()
.screen("example/welcome")
.title("Welcome")
.with(tracker);
tracker.userId = "ABC123"
TrackHelper.track()
.screen("example/welcome")
.title("Welcome")
.with(tracker);
Notes
- The user ID won’t be sent if setAnonymizationState(true) is set.
- For more on the user ID, see this article.
Updated 6 days ago