setUserProperty

open fun setUserProperty(@NonNull key: String, @Nullable value: String)(source)

Sets a user property for analytics tracking.

User properties are attributes you can use to describe segments of your user base, such as language preference or geographic location. These properties are associated with the current user and persist across app sessions.

Example:

// Set a user property
Analytics.setUserProperty("subscription_status", "premium");

// Set a numeric property (converted to string)
Analytics.setUserProperty("login_count", String.valueOf(loginCount));

Note: User property names are case-sensitive and can be up to 24 characters long. User property values can be up to 36 characters long. Setting a property to null will clear it.

Parameters

key

The name of the user property to set. Should be one of the predefined property constants or a custom property name.

value

The value of the user property, or null to clear the property.

See also

* @param value Property value, or null to clear

Throws

if key is null, empty, or exceeds 24 characters