userAgent
The userAgent property returns the default user agent string that the Piwik PRO iOS SDK uses when sending events to the tracker. The property is read-only.
It is useful when you need the same user agent in a WKWebView as the one used by the SDK - for example to make session hash and cross-platform tracking more accurate (Cross-platform tracking).
Syntax
let userAgent = PiwikTracker.sharedInstance()?.userAgentNSString *userAgent = [PiwikTracker sharedInstance].userAgent;Returns
A String with the user agent value (see introduction).
Examples
To use the SDK's user agent in a WKWebView:
let config = WKWebViewConfiguration()
let webView = WKWebView(frame: view.bounds, configuration: config)
webView.customUserAgent = PiwikTracker.sharedInstance()?.userAgentWKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config];
webView.customUserAgent = [PiwikTracker sharedInstance].userAgent;Notes
- For better correlation between events tracked in the app and on the web, use the same user agent in both contexts. See Cross-platform tracking.
Related methods
Updated 15 days ago