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 (for setVisitorID) - Exactly 16 characters, lowercase hex digits 0-9a-f only. 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") == true
BOOL ok = [[PiwikTracker sharedInstance] setVisitorID:@"0123456789abcdef"];

Notes

  • When isAnonymizationEnabled is true, 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 is false, the same stored ID is reused across launches unless you change it with setVisitorID or it expires per visitorIDLifetime.
  • For signed-in users, consider user ID for cross-device stitching; visitorID stays device-oriented unless you override it.

Related methods