Traffic Distribution

Distribute your traffic into different test groups of your 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.

useVariation

You can use components provided by Hackle or use Hooks API to distribute users to specific groups and receive distribution results. When distributing, you must pass the experiment key.

In the example code below, we are passing the experimental key 42, and there are two test groups, A and B.

function App() {
  return (
    // Determines the test group to assign the user in an A/B tests with an experiment key of 42.
    // For undetermined cases, the user is returned to test group A. 
    <HackleExperiment experimentKey={42}> 
      <HackleVariation variation={"A"}>
        <AwesomeFeature />
      </HackleVariation>
      <HackleVariation variation={"B"}>
        <SuperAwesomeFeature />
      </HackleVariation>
    </HackleExperiment>
  )
}
function App() {
  return (
    // ์‹คํ—˜ ํ‚ค๊ฐ€ 42์ธ A/B ํ…Œ์ŠคํŠธ์—์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋…ธ์ถœํ•  ํ…Œ์ŠคํŠธ ๊ทธ๋ฃน์„ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค.
    // ๊ฒฐ์ •ํ•˜์ง€ ๋ชปํ•˜๋Š” ์ƒํ™ฉ์ธ ๊ฒฝ์šฐ ํ…Œ์ŠคํŠธ ๊ทธ๋ฃน A๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
    <HackleExperiment experimentKey={42}>
      {(variation) => {
        switch (variation) { // ํ• ๋‹น๋ฐ›์€ ๊ทธ๋ฃน์— ๋Œ€ํ•œ ๋กœ์ง
          case "A":
            return <AwesomeFeature />
          case "B":
            return <SuperAwesomeFeature />
          default:
            return <AwesomeFeature />
        }
      }}
    </HackleExperiment>
  )
}
function App() {
  // ์‹คํ—˜ ํ‚ค๊ฐ€ 42์ธ A/B ํ…Œ์ŠคํŠธ์—์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋…ธ์ถœํ•  ํ…Œ์ŠคํŠธ ๊ทธ๋ฃน์„ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค.
  // ๊ฒฐ์ •ํ•˜์ง€ ๋ชปํ•˜๋Š” ์ƒํ™ฉ์ธ ๊ฒฝ์šฐ ํ…Œ์ŠคํŠธ ๊ทธ๋ฃน A๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  const variation = useVariation(42)
  
  // ํ• ๋‹น๋ฐ›์€ ๊ทธ๋ฃน์— ๋Œ€ํ•œ ๋กœ์ง
  if (variation === "A") return <AwesomeFeature />
  if (variation === "B") return <SuperAwesomeFeature />
  return <AwesomeFeature />
}

useVariationDetail

The useVariationDetail() Hooks API works the same as useVariation() 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.

// Traffic distribution details 
const decision = useVariationDetail(42)

// Test group determined from distribution
const variation = decision.variation

// Reason for distribution to a test group
const reason = decision.reason

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.

Reason

Description

Distribution Result

SDK_NOT_READY

The SDK is not ready to use.
(e.g. Initialization with the wrong SDK key)

(control) Test Group A

EXPERIMENT_NOT_FOUND

No A/B tests were found for the experimental key you passed.
The experiment key may be incorrect or the experiment may be in archive status.

(control) Test Group A

EXPERIMENT_DRAFT

The A/B test has not yet been started.

(control) Test Group A

EXPERIMENT_PAUSED

The A/B test has been paused.

(control) Test Group A

EXPERIMENT_COMPLETED

The A/B test has ended.

Final winning test group from the experiment

OVERRIDDEN

Users are determined to a specific group by manual assignment.

Manually assigned test group

TRAFFIC_NOT_ALLOCATED

The A/B test is running, but no user has been assigned to any group in the experiment yet.

(control) Test Group A

TRAFFIC_ALLOCATED

The user has been assigned to an A/B test.

Assigned test group

VARIATION_DROPPED

The test group has been excluded from the experiment.

(control) Test Group A

INVALID_INPUT

The input value is not valid.
(e.g. A number was entered in a parameter that requires a character)

(control) Test Group A

EXCEPTION

An unknown error has occurred.

(control) Test Group A


Did this page help you?