setVisitorIdFromDeepLink

The setVisitorIdFromDeepLink() method sets the visitor ID from the pk_vid parameter in a deep link URI. This lets you recognize the same visitor on a website and in an app.

Syntax

tracker.setVisitorIdFromDeepLink(deepLink)
getTracker().setVisitorIdFromDeepLink(deepLink);

Parameters

deepLink (Uri|string, required)

The deep link URI containing the pk_vid query parameter. The pk_vid value must be a valid hexadecimal string with at least 16 characters. Only the first 16 characters are used.

Returns

Whether the visitor ID was successfully set.

  • true if the visitor ID was set
  • false if the visitor ID wasn’t set (invalid format, missing parameter, or null input)

Type: Boolean

Examples

To set the visitor ID from a deep link URI:

val tracker: Tracker = (application as PiwikApplication).tracker
val deepLink = intent.data
tracker.setVisitorIdFromDeepLink(deepLink)
Tracker tracker = ((PiwikApplication) getApplication()).getTracker();
Uri deepLink = getIntent().getData();
tracker.setVisitorIdFromDeepLink(deepLink);

To set the visitor ID from a deep link string:

val tracker: Tracker = (application as PiwikApplication).tracker
tracker.setVisitorIdFromDeepLink("https://example.com?pk_vid=0123456789abcdef")
Tracker tracker = ((PiwikApplication) getApplication()).getTracker();
tracker.setVisitorIdFromDeepLink("https://example.com?pk_vid=0123456789abcdef");

Related methods