Cross-platform tracking

You can set up visitor recognition across both an app and a website. This allows you to recognize the same visitor when they move from a WebView within the app to the website in their mobile browser.

You can also track how users navigate from a website to an app using deep links.

Tracking users transitioning from the mobile browser to the mobile application

The setVisitorIdFromDeepLink method sets a visitor ID from the pk_vid parameter from a provided 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.

The method returns true if the visitor ID is successfully set, false otherwise or when there is nothing to set.

Tracking users transitioning 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 will not be set. The processing service will default to the current value from the Privacy tab 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.