Variation Distribution
When running an A/B Test, you need to distribute users across Variations and implement the logic for each Variation. You can perform this user distribution through the Hackle SDK.
variation
Server SDKs do not support cohort targeting. If targeting includes a cohort, run the test using a Client SDK.
By passing an Experiment Key and User Identifier to the variation() method, you can distribute the user and receive the result. Then implement logic for each Variation.
In the example code below, Experiment Key 42 is passed, the User Identifier is "ae2182e0", and two Variations, A and B, exist.
<?php
require 'vendor/autoload.php';
$client = \Hackle\HackleClients::create("YOUR_SDK_KEY");
$user = \Hackle\Common\HackleUser::builder()
->deviceId("ae2182e0")
->build();
$variation = $client->variation(42, $user);
if ($variation === "A") {
//그룹 A 로직
} elseif ($variation === "B") {
//그룹 B 로직;
}
?>variationDetail
The variationDetail() method works the same as the variation() method and additionally provides the reason for assignment to a specific Variation. This method is useful for checking whether distribution is working correctly.
You must pass the Experiment Key as a parameter. In the example code below, Experiment Key 42 is passed.
The distribution decision reason is returned in the form of SDK_NOT_READY. Refer to 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)
Parameter Settings
You can also receive the parameter values of the distributed Variation through the
variationDetail()method.Since parameter values configured on the Hackle A/B Test screen exist as key-value pairs, you can use the methods below according to the configured parameter type to receive and use the configured parameter value.
getString
Returns parameter values configured as STRING or JSON type.
Returns the default value or the value configured in the rule, depending on the state decision.
getInt
Returns the parameter value configured as Number type as an Int type.
Returns the default value or the value configured in the rule, depending on the state decision.
getFloat
Returns the parameter value configured as Number type as a float type.
Returns the default value or the value configured in the rule, depending on the state decision.
getBool
Returns parameter values configured as Boolean type.
Returns the default value or the value configured in the rule, depending on the state decision.
Last updated