setVisitorId
The setVisitorId() method sets a custom visitor ID. By default, the visitor ID is automatically set when the tracker instance is created and is stored between app launches. The visitor ID helps to recognize sessions belonging to the same user.
Syntax
getTracker().setVisitorId("visitorID");
tracker.visitorId = "visitorID"
Parameters
visitorID (string, required)
The visitor ID set for a specific user. Format: 16-character hexadecimal string. Example: 0123456789abcdef
.
Examples
To set a visitor ID to 0123456789abcdef
:
getTracker().setVisitorId("0123456789abcdef");
tracker.visitorId = "0123456789abcdef"
Notes
- If setAnonymizationState(true) is set, a new visitor ID is created each time the app is launched.
- Each user should have a unique visitor ID assigned. The visitor ID shouldn’t change between app launches.
- We recommend using the user ID instead of the visitor ID.
Updated 6 days ago