Variation Distribution
When running an A/B Test, you need to distribute users across variations and write logic for each variation. You can use the Hackle SDK to handle this distribution.
variation
Pass the Experiment Key to the variation() method to distribute the user and receive the result.
Experiment Key (key)
int
Required
Example
The example code below passes Experiment Key 42, where there are two variations: A and B.
import io.hackle.android.HackleApp
import io.hackle.sdk.common.Variation
// 실험 키가 42인 A/B 테스트에서 사용자에게 노출할 테스트 그룹을 결정합니다.
// 결정하지 못하는 상황인 경우 테스트 그룹 A를 반환합니다.
val variation = hackleApp.variation(42)
// 할당받은 그룹에 대한 로직
if (variation == Variation.A) {
// 그룹 A 로직
} else if (variation == Variation.B) {
// 그룹 B 로직
}import io.hackle.android.HackleApp;
import io.hackle.sdk.common.Variation;
// 실험 키가 42인 A/B 테스트에서 사용자에게 노출할 테스트 그룹을 결정합니다.
// 결정하지 못하는 상황인 경우 테스트 그룹 A를 반환합니다.
Variation variation = hackleApp.variation(42);
// 할당받은 그룹에 대한 로직
if (variation == Variation.A) {
// 그룹 A 로직
} else if (variation == Variation.B) {
// 그룹 B 로직
}variationDetail
The variationDetail() method works the same as variation() but also provides the reason for the distribution decision. This method is useful for verifying that distribution is working correctly.
Experiment Key (key)
int
Required
Example
The example code below passes Experiment Key 42.
Distribution Reason
The distribution reason is returned in the format SDK_NOT_READY. See the table below for details.
SDK_NOT_READY
The SDK is not ready to use.
(e.g., initialization attempted with an invalid SDK Key)
A (Control Group)
EXPERIMENT_NOT_FOUND
No A/B Test was found for the provided Experiment Key. The Experiment Key may be incorrect, or the experiment may be archived.
A (Control Group)
NOT_IN_MUTUAL_EXCLUSION_EXPERIMENT
The experiment is included in Mutually Exclusive Settings, but the user was not assigned to that Mutually Exclusive Group.
A (Control Group)
EXPERIMENT_DRAFT
The A/B Test is in draft state.
A (Control Group)
EXPERIMENT_PAUSED
The A/B Test is paused.
A (Control Group)
EXPERIMENT_COMPLETED
The A/B Test has ended.
Winning Variation selected at completion
OVERRIDDEN
The user was assigned to a specific group by Override.
Override-assigned group
NOT_IN_EXPERIMENT_TARGET
The user is not an A/B Test target.
A (Control Group)
TRAFFIC_NOT_ALLOCATED
The A/B Test is running, but the user was not allocated to the test.
A (Control Group)
TRAFFIC_ALLOCATED
The user has been allocated to the A/B Test.
Allocated group
VARIATION_DROPPED
The originally allocated group has been removed from the test.
A (Control Group)
INVALID_INPUT
The input value is invalid.
A (Control Group)
EXCEPTION
An unknown error occurred.
A (Control Group)
Parameters
The
variationDetail()method also returns the parameter values for the assigned variation.The
Decisioninstance returned byvariationDetail()contains aParameterConfigobject with all parameter configuration.Since parameters set on the Hackle A/B Test screen exist as key-value pairs, you can use the methods below to retrieve parameter values according to the configured parameter type.
You can query the configured values for the assigned variation using the functions below.
getString
Returns a parameter value configured as STRING or JSON type.
getInt
Returns a parameter value configured as NUMBER type as an int.
getDouble
Returns a parameter value configured as NUMBER type as a double.
getLong
Returns a parameter value configured as NUMBER type as a long.
getBoolean
Returns a parameter value configured as Boolean type.
Example
Last updated