Variation Distribution
When running an A/B Test, you need to assign users to Variations and implement logic for each Variation. You can use the Hackle SDK to handle this user distribution.
Unity SDK is built on top of Android and iOS SDKs. In Unity Editor, all calls return Group A.
variation
Pass the Experiment Key to the Variation() method to assign users to a Variation and receive the result. Then implement logic for each Variation.
In the example code below, Experiment Key 42 is passed, and there are two Variations: A and B.
// Determines which Variation to show to the user in the A/B Test with Experiment Key 42.
// Returns Variation A if a decision cannot be made.
string variation = hackle.Variation(42);
// Logic for the assigned Variation
if (variation == "A") {
// Group A logic
} else if (variation == "B") {
// Group B logic
}variationDetail
The VariationDetail() method works the same as Variation() but additionally provides the reason for being assigned to a specific group. This method is useful for verifying that distribution is working correctly.
You must pass the Experiment Key as a parameter. In the example code below, Experiment Key 42 is passed.
The decision reason is returned in a format such as 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)
Parameters
You can also receive the parameter values for the assigned Variation through the
VariationDetail()method.You can use the
GetBoolean(),GetDouble(),GetInt(),GetLong(), andGetString()methods to retrieve the parameter values configured in the A/B Test screen. If you change values in the A/B Test parameter settings screen, the updated values are applied in the code.Since parameter values configured in the Hackle A/B Test screen are stored as key-value pairs, use the methods below according to the parameter type to retrieve the configured values.
GetString
Returns parameter values configured as STRING or JSON type.
Returns the value configured for the assigned Variation.
GetInt
Returns parameter values configured as Number type as an Int.
Returns the value configured for the assigned Variation.
GetDouble
Returns parameter values configured as Number type as a Double.
Returns the value configured for the assigned Variation.
GetLong
Returns parameter values configured as Number type as a Long.
Returns the value configured for the assigned Variation.
GetBoolean
Returns parameter values configured as Boolean type.
Returns the value configured for the assigned Variation.
Last updated