User identifiers are used to uniquely identify different users.
Refer to the Managing User Identifiers document for information.
The Unity SDK includes features to automatically manage device identifiers. Users can be automatically identified without having to manually pass the user identifier separately.
Here's how to get the SDK-managed user identifier:
Hackle hackle = Hackle.GetInstance(); // Retrieve the internally managed device ID string deviceId = hackle.GetDeviceId();
This method is used in order to directly pass a user identifier as a parameter. The identifier to be delivered can be a directly managed primary key, device identifier, member ID, email, hash value, etc.
The following is an example of sending a user event after distributing users to a test group.
Hackle hackle = Hackle.GetInstance(); // 1. Using SDK-managed identifiers - do not pass user identifiers in parameters string variation = hackle.Variation(experimentKey); hackle.track(event); // 2. Using user identifiers managed yourself - pass user identifiers in parameters HackleUser user = new HackleUser("ae2182e0"); string variation = hackle.Variation(experimentKey, user); hackle.Track(event, user);
Hackle SDK supports adding properties to a User object.
- Properties must be sent as a pair with both a property name (key) and a property value (value).
- The maximum number of properties that can be added to a User object is 64.
- The key should be set as a general name, but easily identifiable.
- The character limit is 64 characters.
- It is not case-sensitive. For example, AGE and age are recognized as the same key.
- The value supports boolean, string, and number types.
- In the case of string type, the character limit is 64 characters.
- The string type is case-sensitive. For example, APPLE and apple are recognized as different property values.
- In the case of number type, up to 15 integers and up to 6 decimal places are supported.
User objects are used as parameters in distributing user traffic into test groups, determining feature flags, and sending user events.
Refer to the example code and add the desired properties to each user. In the example below, you can see that three properties (
is_paying_user) have been added.
Hackle hackle = Hackle.GetInstance(); Dictionary<string, object> properties = new Dictionary<string, object>(); properties["age"] = 30; properties["grade"] = "GOLD"; properties["is_paying_user"] = false; HackleUser user = new HackleUser(userId, properties); // Traffic distribution to test groups string variation = hackle.Variation(experimentKey, user); // Feature flag determination bool featureOn = hackle.IsFeatureOn(featureKey, user); // Send user events hackle.Track(event, user);
Updated 9 months ago