sessionHash
Session hash is a Piwik PRO feature that that adds session-level context to analytics data. Depending on your Piwik PRO configuration, it can help associate activity across environments, such as a website and mobile app or multiple devices.
The sessionHash property controls how the SDK flags analytics events: request session hash (.enabled), don't request session hash (.disabled), or let the privacy settings configured for the tracked app decide (.notSet).
The selected value is sent as the sh request parameter. The SDK remembers this setting between app launches.
Syntax
PiwikTracker.sharedInstance()?.sessionHash = sessionHash[PiwikTracker sharedInstance].sessionHash = sessionHash;Parameters
-
sessionHash(SessionHash, required) One of: -
.enabled: Sendssh=1. -
.disabled: Sendssh=0. This is the default when no value has been stored yet. -
.notSet: Omitsshso the privacy settings configured for the app determine how the data is processed.
Examples
To turn session hash on:
PiwikTracker.sharedInstance()?.sessionHash = .enabled[PiwikTracker sharedInstance].sessionHash = Enabled;To omit sh and follow server-side privacy defaults:
PiwikTracker.sharedInstance()?.sessionHash = .notSet[PiwikTracker sharedInstance].sessionHash = NotSet;To read the current value:
let currentValue = PiwikTracker.sharedInstance()?.sessionHashSessionHash currentValue = [PiwikTracker sharedInstance].sessionHash;Notes
If visitorIDLifetime is enabled (greater than zero), the SDK forces session hash off by sending sh=0.This behavior applies for 31 minutes after the current visitor ID is set, including when the visitor ID is replaced after it expires. During that time, the sessionHash setting has no effect and the SDK always sends sh=0.
After 31 minutes, the SDK uses the sessionHash value again.
For cross-environment tracking, use the same user agent in WKWebView when appropriate. See userAgent and Cross-platform tracking.
Related methods
Updated 2 months ago