Traffic Distribution

Traffic distribution into the different test groups of the A/B test.

When conducting an A/B test, not only do you need to distribute your users to different test groups, you also need to write a logic for each test group. After the integration stages, the distribution of users into different test groups can be done through the Hackle SDK.

📘

Test Groups

The test groups are basically the different groups that are exposed to the versions (features, screens, algorithms, etc) of a page of an experiment. Test groups include both the control test group A and treatment test groups B, C, D, etc., that are exposed to the "improved" versions of the pages.
The test groups can be set on the dashboard and further information on the test groups can be found on the What is a Test Group? document.

variation

Think of the variation as the term that is equivalent to different versions of the page being shown to users on your app or browser.
By passing the experiment key and user identifier to the variation() method, you can distribute particular users and receive the result for the specific experiment. After that, we implement the logic of the page version applicable for each test group.

In the example code below, we are passing the experimental key 42, the user identifier is "ae2182e0" . There are two test groups, A and B.

<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SERVER_SDK_KEY");

$user = \Hackle\Common\HackleUser::of("ae2182e0");

$variation = $client->variation(42 , $user);

if($variation == \Hackle\Common\Variation::A) {
    //그룹 A 로직
}
else if($variation == \Hackle\Common\Variation::B) {
    //그룹 B 로직;
}

?>

variationDetail

The variationDetail() method works the same as the variation() method but provides the reason for a user being distributed to a specific group. This method can be a useful tool to see if the distribution is working properly.
You must pass the experiment key as a parameter. For the example code below, we are passing experimental key 42.

<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SERVER_SDK_KEY");

$user = \Hackle\Common\HackleUser::of("ae2182e0");

// Traffic distribution details 
$decision = $client->variationDetail(42 , $user);

// Test group determined from distribution
$variation = $decision->getVariation();

// Reason for distribution to a test group
$reason = $decision->getReason();

?>

You will receive the reason for the distribution or the allocation of a specific user to a specific test group in the form of SDK_NOT_READY. Please refer to the table below for the full list of different distribution reasons.

ReasonDescriptionDistribution Result
SDK_NOT_READYThe SDK is not ready to use.
(e.g. initialized with the wrong SDK key)
(control) Test Group A
EXPERIMENT_NOT_FOUNDNo A/B tests were found for the experimental key you passed.
The experiment key may be incorrect or the experiment may be in the archive status.
(control) Test Group A
NOT_IN_MUTUAL_EXCLUSION_EXPERIMENTIf an experiment is included in the mutually exclusive settings but is not assigned to the corresponding mutually exclusive group.(control) Test Group A
EXPERIMENT_DRAFTThe A/B test has not yet been started (in draft mode).(control) Test Group A
EXPERIMENT_PAUSEDThe A/B test has been paused.(control) Test Group A
EXPERIMENT_COMPLETEDThe A/B test has ended.Final winning test group from the experiment
OVERRIDDENUsers are distributed to a specific test group by manual assignment.Manually assigned test group
TRAFFIC_NOT_ALLOCATEDA/B test is running, but user has not been assigned to the experiment.(control) Test Group A
TRAFFIC_ALLOCATEDUser has been assigned to a test group in the A/B test.Assigned test group
VARIATION_DROPPEDThe test group was removed from the A/B test.(control) Test Group A
EXCEPTIONAn unknown error has occurred.(control) Test Group A

Parameter

  • Parameter values of the distributed group can also be provided through the variationDetail() method.
  • Parameter values you've set on the dashboard exists in the form of key and value, therefore you can use the method below to set the parameter values.

getString

  • Returns the parameter value set to STRING, JSON type.
  • Returns the set value of the distributed group.
<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SERVER_SDK_KEY");

$user = \Hackle\Common\HackleUser::of("ae03e1adf");

$decision = $client->variationDetail(42, $user);

$strValue = $decision->getString("parameter_key_string_type", "defaultValue");
$jsonValue = $decision->getString("parameter_key_json_type", "defaultValue");

?>

getInt

  • Returns the parameter value set to Number type as Int type.
  • Returns the set value of the distributed group.
<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SERVER_SDK_KEY");

$user = \Hackle\Common\HackleUser::of("ae03e1adf");

$decision = $client->variationDetail(42, $user);

$intValue = $decision->getInt("parameter_key_number_type", 0);

?>

getFloat

  • Returns the parameter value set to Number type as Float type.
  • Returns the set value of the distributed group.
<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SERVER_SDK_KEY");

$user = \Hackle\Common\HackleUser::of("ae03e1adf");

$decision = $client->variationDetail(42, $user);

$floatValue = $decision->getFloat("parameter_key_number_type", 0.0);

?>

getBool

  • Returns the parameter value set to Bool type.
  • Returns the set value of the distributed group.
<?php
  
require 'vendor/autoload.php';

$client = \Hackle\HackleClients::create("YOUR_SERVER_SDK_KEY");

$user = \Hackle\Common\HackleUser::of("ae03e1adf");

$decision = $client->variationDetail(42, $user);

$boolValue = $decision->getBool("parameter_key_bool_type", true);

?>