Cross-platform tracking
You can set up visitor recognition across an app and a website. This helps you recognize the same visitor when they move from a WebView in 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 who move from the mobile browser to the mobile app
The setVisitorIdFromDeepLink method sets a visitor ID from the pk_vid parameter in the provided deep link:
const result = await PiwikProSdk.setVisitorIdFromDeepLink('https://example.com?pk_vid=0123456789abcdef');deepLink: string– A string that represents a deep link. The deep link must contain thepk_vidparameter.
The method returns whether the visitor ID was set.
true: The visitor ID was set.false: The visitor ID wasn’t set, or there was no visitor ID to set.
Tracking users move from the mobile app to the WebView
If the session hash feature is enabled, or if you want more accurate tracking, set the same user agent in the WebView that's used in the Piwik PRO SDK.
The getUserAgent method returns the default user agent parameter used in the Piwik PRO SDK:
const userAgent = await PiwikProSdk.getUserAgent();Session hash
The sessionHash field controls the session hash feature by sending the sh parameter to the tracker.
You can set it using the setSessionHash method:
import { SessionHash } from '@piwikpro/react-native-piwik-pro-sdk';
await PiwikProSdk.setSessionHash(SessionHash.ENABLED);sessionHash: SessionHash(required) – An enum with following options:SessionHash.ENABLED– Theshparameter is set to1.SessionHash.DISABLED– Theshparameter is set to0.SessionHash.NOT_SET– Theshparameter isn't sent. The processing service uses the current value from the Privacy tab in global or app settings.
The Piwik PRO SDK saves the provided parameter and keeps it the next time the SDK is initialized.
You can get the sessionHash value using the getSessionHash method:
const sessionHash = await PiwikProSdk.getSessionHash();The default value is set to SessionHash.DISABLED.
Updated about 5 hours ago