setVisitorIDLifetime

The setVisitorIDLifetime() method sets how long the visitor ID is kept. After this time, the SDK generates a new visitor ID and deletes all parameters related to the user’s activity, such as the time of the first event sent. This simulates a new visitor. The default value is 0, which means the visitor ID never expires.

Syntax

await PiwikProSdk.setVisitorIDLifetime(visitorIDLifetime);

Parameters

visitorIDLifetime (number, required)

The lifetime of the visitor ID, in seconds. If the value is less than or equal to 0, the visitor ID never expires. Default value: 0.

Examples

To set the visitor ID lifetime to 30 days (30x24x60x60 seconds):

await PiwikProSdk.setVisitorIDLifetime(30 * 24 * 60 * 60);

Notes

  • When the SDK is upgraded to a newer version, the visitor ID creation time is set to the first SDK initialization after the upgrade.

Related methods