For the complete documentation index, see llms.txt. This page is also available as Markdown.

Client User Identifier

On the client, you can use a User Identifier in two ways.

  • Using the device identifier managed internally by the SDK

  • Using a custom identifier

Using the Device Identifier Managed Internally by the SDK

Client-side SDKs include functionality for managing the device identifier. Therefore, users can be automatically identified without passing a separate User Identifier.

For JavaScript, Android, and iOS, you can obtain the device identifier managed by the SDK — refer to the example code below.

// Variation distribution
const experimentKey = 42
const variation = hackleClient.variation(experimentKey)

// Event tracking
hackleClient.track("purchase")

// Get the internally managed device identifier
const userId = Hackle.getUserId()
// Variation distribution
int experimentKey = 42;
Variation variation = hackleApp.variation(experimentKey);

// Event tracking
hackleApp.track("purchase");

// Get the internally managed device identifier
String deviceId = hackleApp.getDeviceId();

Using a Custom Identifier

The SDK identifies users via the identifier passed as a parameter. The identifier you pass can be a Primary Key you manage yourself, a device identifier, a member ID, an email address, a hash value, etc.

Example: Creating a Custom Identifier

If you only need data for logged-in users, you can use the member ID or email address used at login as the identifier.

However, if you need to include non-logged-in users, it is recommended to use a value that can distinguish users based on the app, device, or browser. (For mobile apps, use a UUID or ADID value; for PC/Mobile web, use a cookie value.)

Below is an example of generating a User Identifier based on cookies.

Last updated