User Identifier and Property

📘

Managing User Identifiers

User identifiers are used to uniquely identify users. For more information on the meaning and importance of user identifiers and how to choose them, please refer to the Managing User Identifiers document.

Use your own managed user identifiers

Since server-side SDKs cannot identify users by itself, you must always pass user identifiers directly as parameters. The identifier you pass can be a directly managed Primary Key, device identifier, user ID, email, hash value, and more.

Example

Here's an example of distributing users into test groups and sending user events after the test group allocation:

import "github.com/hackle-io/hackle-go-sdk/hackle"

user := hackle.NewUserBuilder().ID("ae2182e0").Build()

// Distributing users into test groups
variation := hackleClient.Variation(42, user)

// Sending user events
hackleClient.Track(event, user)

Additional Identifiers

You can send additional identifiers, other than the default identifier, using the following example code:

import "github.com/hackle-io/hackle-go-sdk/hackle"

user := hackle.NewUserBuilder().
    ID("ae2182e0").                 // Default identifier
    DeviceID("ae2182e0").           // Device ID (Hackle integrated identifier supported)
    UserId("143").                  // User ID (Hackle integrated identifier supported)
    Identifier("myCustomId", "42"). // Custom ID
    Build()

Properties

The Hackle SDK supports adding properties to user objects.

  • Properties must be sent as pairs of property names (keys) and property values.
  • You can add up to 64 properties to a user object.

Property Names (Keys)

  • It is recommended to create property names similar to regular variable names for easy identification.
  • The character limit is 64 characters.
  • Case is not sensitive. For example, "AGE" and "age" are considered the same property name.

Property Values

  • Values can be boolean, string, or number types.
  • For string types, the character limit is 64 characters.
  • String types are case-sensitive. For example, "APPLE" and "apple" are recognized as different property values.
  • For number types, integers can have a maximum of 15 digits, and decimals can have a maximum of 6 digits.

Example

User objects are used as parameters in distributing users into test groups, making feature flag decisions, and sending user events.
In the example below, you can see that three properties (age, grade, is_paying_user) have been added to the user object:

import "github.com/hackle-io/hackle-go-sdk/hackle"

user := hackle.NewUserBuilder().
    ID("ae2182e0").
    Property("age", 42).
    Property("grade", "GOLD").
    Property("is_paying_user", false).
    Build()
    
// Distributing users into test groups  
variation := hackleClient.Variation(experimentKey, user)

// Making feature flag decisions
featureOn := hackleClient.IsFeatureOn(featureKey, user)

// Sending user events
hackleClient.track(event, user)