Cross-platform tracking

You can recognize visitors across your app and website. This is useful when a visitor moves from a WebView in the app to the website in their mobile browser.

You can also track when visitors move from a website to an app with deep links.

Tracking users who move from the mobile browser to the mobile app

The setVisitorIdFromDeepLink method sets a visitor ID from the pk_vid parameter in a deep link:

final bool result = await FlutterPiwikPro.sharedInstance
    .setVisitorIdFromDeepLink('https://example.com?pk_vid=0123456789abcdef');
  • String deepLink – a string representation of a deep link. The deep link must contain the pk_vid parameter.

Returns

Whether the visitor ID was set successfully.

Type: boolean.

  • true: The visitor ID was set.
  • false: The visitor ID wasn't set because the parameter is missing, the format is invalid, or the input is empty.

Tracking users move from the mobile application to the WebView

If the session hash feature is enabled, or if you would like the tracking to be more accurate, set the same user agent in the WebView as is used in the Piwik PRO SDK.

The getUserAgent method returns the default user agent parameter used in the Piwik PRO SDK:

final String userAgent = await FlutterPiwikPro.sharedInstance.getUserAgent();

Session hash

The sessionHash field provides on-demand control of the Session Hash feature by sending the sh parameter to the tracker.

You can set it using the setSessionHash method:

await FlutterPiwikPro.sharedInstance.setSessionHash(SessionHash.enabled);
  • SessionHash sessionHash (required) – An enum with options:
    • SessionHash.enabled – The sh parameter will be set to 1.
    • SessionHash.disabled – The sh parameter will be set to 0.
    • SessionHash.notSet – The sh parameter isn't set. The processing service will default to the current value from Privacy in the global or app settings.

The Piwik PRO SDK will persist the provided parameter and hold the state next time the SDK is initialized.

You can get the sessionHash value using the getSessionHash method:

final SessionHash sessionHash = await FlutterPiwikPro.sharedInstance.getSessionHash();

The default value is set to SessionHash.disabled.