User Identifier and Property

Managing User Identifiers

User identifiers are used to uniquely identify different users.
Refer to the Managing User Identifiers document for an in-depth definition and understanding of why user identifiers are so important during experimentation.

Use your own managed user identifiers

Since the server-side SDK is not user-specific, you must always always pass the user identifier directly as a parameter.
The identifier delivered can be a directly managed primary key, device identifier, member ID, email, hash value, etc.

Example

The following is an example of tracking and sending user events after distributing your traffic into different test groups.

uesr = Hackle.user('ae2182e0')

# Traffic distribution
variation = hackle_client.variation(experiment_key=42, user=user)

# Send user events 
hackle_client.track(event=event, user=user)

Property

Hackle SDK supports adding properties to a User object.

  • Properties must be sent as a pair with both property name (key) and a property value (value).
  • The maximum number of properties that can be added to a User object is 64.

Property Key (Name)

  • 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.

Property Value

  • 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.

Example

User objects are used as parameters in distributing 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 (age, grade, is_paying_user) have been added.

user = Hackle.user(id='ae2182e0',
                  age=30,
                  grade='GOLD',
                  is_paying_user=False
                  )

# Traffic distribution
variation = hackle_client.variation(experiment_key, user)

# Feature flag determination
feature_on = hackle_client.is_feature_on(feature_key, user)

# Send user events 
hackle_client.track(event, user)

Additional Identifiers

In addition to the default identifier, additional identifiers can be sent through the example code below.

from hackle.model import HackleUser

user = HackleUser.builder() \
                 .id('ae2182e0') \
                 .user_id('143') \
                 .device_id('ae2182e0') \
                 .session_id('1673508397731.9bdcc236') \
                 .identifier('my_custom_id', '42') \
                 .identifier('other_id', '320') \
                 .property('age', 30) \
                 .property('grade', 'GOLD') \
                 .property('is_paying_user', False) \
                 .build()
from hackle.model import HackleUser

user = HackleUser(
  id='ae2182e0',
  user_id='143',
  device_id='ae2182e0',
  identifiers={
    'my_custom_id': '42'
  },
  properties={
    'age': 30,
    'grade': 'GOLD',
    'is_paying_user': False
  }
)