setUserId

The setUserId() method sets the user ID for a specific user. You can use the same identifier as in your content management system (CMS), customer relationship management (CRM) or sales system. The user ID helps to recognize the user across devices.

Syntax

await FlutterPiwikPro.sharedInstance.setUserId('userId');

Parameters

userId (string, required)

A non-empty, unique identifier for the user.

For example, you can use a customer ID.

The user ID:

  • Must be unique for each user.
  • Can be up to 1024 bytes, which is 1024 ASCII characters.

Examples

To set a user ID as ABC123 and send it with a screen view:

await FlutterPiwikPro.sharedInstance.setUserId('ABC123');

Notes

  • The user ID isn't sent when setAnonymizationState(true) is enabled. Read more.