> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/sdk/user-identifier/server-user-identifier.md).

# Server User Identifier

Since users cannot be identified on the server, you must **always pass a custom identifier as a parameter**.

```java
// Variation distribution
long experimentKey = 42L;
User user = User.builder().userId("ae2182e0");
Variation variation = hackleClient.variation(experimentKey, user);

// Event tracking
hackleClient.track("purchase", user);
```

```python
# Variation distribution
uesr = Hackle.user(user_id='ae2182e0')
variation = hackle_client.variation(experiment_key=42, user=user)

# Event tracking
event = Hackle.event(key='purchase')
hackle_client.track(event=event, user=user)
```

```javascript
// Variation distribution
const experimentKey = 42;
const user = { userId: "ae2182e0" };
hackleClient.variation(experimentKey, user);

// Event tracking
hackleClient.track("purchase", user);
```

```php
// Variation distribution
$experimentKey = 42;
$userId = 'ae2182e0'
$user = \Hackle\Common\HackleUser::builder()->userId($userId)->build();
$variation = $hackleClient->variation($experimentKey, $user);

// Event tracking
$hackleClient->track('purchase', $user);
```

```ruby
# Variation distribution
user = Hackle.user(user_id: 'ae2182e0')
variation = hackle_client.variation(experiment_key: 42, user: user)

# Event tracking
event = Hackle.event(key: 'purchase')
hackle_client.track(event: event, user: user)
```

## Matching Identifiers Between Client and Server

When using the Client and Server SDKs simultaneously, you can align the identifier for the same user across both environments.

In this case, it is recommended to pass the identifier via an HTTP header during client-server API communication, as shown below.

```http
X-DEVICE-ID: a3017217-3d46-4d7e-8d88-a0a905709fe4
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hackle.io/en/development-guide/sdk/user-identifier/server-user-identifier.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
