userAgent

The userAgent property returns the default user agent string used by the Piwik PRO iOS SDK uses when sending events. The property is read-only.

Use this property when you need a WKWebView to use the same user agent as the SDK, for example when implementing session hash or cross-platform tracking cross-platform tracking.

Syntax

let userAgent = PiwikTracker.sharedInstance()?.userAgent
NSString *userAgent = [PiwikTracker sharedInstance].userAgent;

Returns

A String containing the user agent value used by the SDK.

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()?.userAgent
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config];
webView.customUserAgent = [PiwikTracker sharedInstance].userAgent;

Notes

  • To improve 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


Did this page help you?