# Variation Distribution Result

When running an A/B Test, you need to distribute users to test groups and write the logic for each test group. User distribution can be done through the Hackle SDK.

{% hint style="info" %}
Variation

A Variation refers to the current version (Control) and the improved version(s) (Treatment) that are the subjects of the test. There can be 1 or more Treatment groups.

You can configure them in the Dashboard. For how to manage test groups, refer to the [A/B Test Settings](/en/ab-test/management/ab-settings.md) document.
{% endhint %}

## variation

By passing the **Experiment Key** to the `variation()` method, you can distribute users and receive the result. Then implement the logic for each test group.

In the example code below, Experiment Key 42 is being passed, and there are two test groups: A and B.

```java
// 실험 키가 42인 A/B 테스트에서 사용자에게 노출할 테스트 그룹을 결정합니다.
// 결정하지 못하는 상황인 경우 테스트 그룹 A를 반환합니다.
Variation variation = hackleApp.variation(42);

// 할당받은 그룹에 대한 로직
if (variation == Variation.A) {
  // 그룹 A 로직
} else if (variation == Variation.B) {
  // 그룹 B 로직
}
```

```kotlin
// 실험 키가 42인 A/B 테스트에서 사용자에게 노출할 테스트 그룹을 결정합니다.
// 결정하지 못하는 상황인 경우 테스트 그룹 A를 반환합니다.
val variation = hackleApp.variation(42)

// 할당받은 그룹에 대한 로직
if (variation == Variation.A) {
  // 그룹 A 로직
} else if (variation == Variation.B) {
  // 그룹 B 로직
}
```

## variationDetail

The `variationDetail()` method works the same as the `variation()` method and additionally provides the reason why the user was distributed to a specific group. This method is useful for checking whether distribution is working correctly.\
You need to pass the Experiment Key as a parameter. In the example code below, Experiment Key 42 is being passed.

```java
// 분배 결정 상세
Decision decision = hackleApp.variationDetail(42);

// 분배 그룹
Variation variation = decision.getVariation();

// 분배 결정 사유
DecisionReason reason = decision.getReason();
```

```kotlin
// 분배 결정 상세
val decision = hackleApp.variationDetail(42)

// 분배 그룹
val variation = decision.variation

// 분배 결정 사유
val reason = decision.reason
```

The distribution decision reason is received in the format **`SDK_NOT_READY`**, for example. For more details, refer to the table below.

| Reason                      | Description                                                                                                                                      | Distribution Result                 |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------- |
| SDK\_NOT\_READY             | The SDK is not ready. Or an initialization was attempted with an invalid SDK Key.                                                                | Default group (A)                   |
| EXPERIMENT\_NOT\_FOUND      | The A/B Test for the passed Experiment Key could not be found. The Experiment Key may be incorrect, or the experiment may be in Archived status. | Default group (A)                   |
| EXPERIMENT\_DRAFT           | The A/B Test is in Draft status.                                                                                                                 | Default group (A)                   |
| EXPERIMENT\_PAUSED          | The A/B Test is in Paused status.                                                                                                                | Default group (A)                   |
| EXPERIMENT\_COMPLETED       | The A/B Test has been completed.                                                                                                                 | Winner group selected at completion |
| OVERRIDDEN                  | The user has been assigned to a specific group by Override.                                                                                      | The overridden group                |
| NOT\_IN\_EXPERIMENT\_TARGET | The user is not a target of the A/B Test.                                                                                                        | Default group (A)                   |
| TRAFFIC\_NOT\_ALLOCATED     | The A/B Test is running but the user has not been allocated to the test.                                                                         | Default group (A)                   |
| TRAFFIC\_ALLOCATED          | The user has been allocated to the A/B Test.                                                                                                     | The allocated group                 |
| VARIATION\_DROPPED          | The originally allocated group has been dropped from the test.                                                                                   | Default group (A)                   |
| EXCEPTION                   | An unknown error occurred.                                                                                                                       | Default group (A)                   |


---

# Agent Instructions: 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:

```
GET https://docs.hackle.io/en/ab-test/group-distribution/ab-variation-result.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
