visitorID
The visitorID property is the read-only visitor identifier used for tracking. The SDK stores it between app launches for the same site unless anonymization or visitor ID lifetime settings replace it. To use your own identifier, call setVisitorID(newVisitorID:) with a 16-character lowercase hexadecimal string, for example, 0123456789abcdef.
Syntax
PiwikTracker.sharedInstance()?.setVisitorID(newVisitorID: "0123456789abcdef")[[PiwikTracker sharedInstance] setVisitorID:@"0123456789abcdef"];Parameters
- newVisitorID (string, required)
The visitor ID to set. Must containt exactly 16 characters, lowercase hexadecimal digits (0-9,a-f). If the format is invalid, the SDK leaves the stored visitor ID unchanged.
Examples
Use an if statement and the returned Bool to confirm whether the visitor ID was updated:
let ok = PiwikTracker.sharedInstance()?.setVisitorID(newVisitorID: "0123456789abcdef") == trueBOOL ok = [[PiwikTracker sharedInstance] setVisitorID:@"0123456789abcdef"];Notes
- When
isAnonymizationEnabledistrue, the SDK generates a new visitor ID the first time it needs one during an app run, and stores it. As a result, the value can change between app launches.
When anonymization isfalse, the same ID is reused across launches unless you change it withsetVisitorIDor it expires according to visitorIDLifetime. - For signed-in users, consider user ID for cross-device tracking. The
visitorIDis device-specific unless you override it.
Related methods
Updated 2 months ago
Did this page help you?