visitorID
The visitorID property is the read-only visitor identifier the SDK uses when tracking. The SDK persists it between app launches for the same site, unless anonymization or lifetime rules replace it (see Notes). 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(forsetVisitorID) - Exactly 16 characters, lowercase hex digits0-9a-fonly. If the format is invalid, the call does nothing and leaves the stored visitor ID unchanged.
Examples
Use if / the returned Bool to confirm the update:
let ok = PiwikTracker.sharedInstance()?.setVisitorID(newVisitorID: "0123456789abcdef") == trueBOOL ok = [[PiwikTracker sharedInstance] setVisitorID:@"0123456789abcdef"];Notes
- When
isAnonymizationEnabledistrue, the SDK issues a new visitor ID when it first needs one in a run (and persists it), so the value can change between app launches. When anonymization isfalse, the same stored ID is reused across launches unless you change it withsetVisitorIDor it expires per visitorIDLifetime. - For signed-in users, consider user ID for cross-device stitching;
visitorIDstays device-oriented unless you override it.
Related methods
Updated 15 days ago