setUserId

open fun setUserId(@Nullable uid: String)(source)

Sets the user ID for analytics tracking across all sessions and devices.

This ID will be associated with all subsequent events until it's changed or cleared. Use this to track user behavior across different devices and sessions.

Example:

// Set user ID after login
Analytics.setUserId("user_123");

// Clear user ID after logout
Analytics.setUserId(null);

Note: The user ID should not contain personally identifiable information (PII). Use a hashed or anonymized identifier instead.

Parameters

uid

A unique identifier for the user, or null to clear the current user ID.

See also