Skip to main content
This tutorial describes how to request experiment results and determine winning variations using the Automation API. It follows previous tutorials on creating experiments, modifying variations, associating goals and segments, and launching experiments.

Requirements

  • access_token
The Automation API requires an access token. Retrieve the token programmatically by following the instructions in the Obtaining an access token section.
  • experimentId
The experimentId is the numeric identifier of the experiment you want results for. You can find it in the URL of the Kameleoon app while viewing the experiment (for example, https://app.kameleoon.com/.../experiments/188308/...). For feature flag experiments, the ID is shown in the Rollout Planner.

Goal

The tutorial uses the following example experiment:
Experiment_188308
This experiment, called Product Page Redesign, includes two variations in addition to the original version: Redesign 1 (ID 828220) and Redesign 2 (ID 828221). While the experiment has several objectives, this tutorial will focus solely on the main goal, which is to track insurance subscriptions through Click Tracking.
The tutorial also applies to Feature Flag experiments; however, use the https://api.kameleoon.com/feature-flags/* endpoints instead of https://api.kameleoon.com/experiments/*:The experimentId is in the Rollout Planner:

How result retrieval works

Retrieving results is a two-step process:
  1. Request results — POST to /experiments/{experimentId}/results. The response returns a dataCode hash, not the results themselves.
  2. Poll for results — GET /results?dataCode=<dataCode> to retrieve the actual data.
The two cases in step 1 differ only in how you authenticate: directly with your access token (Case 1), or via a shared token that lets unauthenticated users view results (Case 2).

1. Retrieve the data code

The following key body parameters control what the report includes. For the full parameter reference, see the Request experiment’s results endpoint.

Case 1: Retrieve results directly

Send a POST request to the Request experiment’s results endpoint using your access token. Example:
Response:
Pass this dataCode to step 2 to retrieve the actual results.

Case 2: Share results without authorization

Use this approach to let users view results without an access token — for example, to share a live results view with a stakeholder.

1. Retrieve a SharedToken

Fetch a SharedToken from the Share experiment results endpoint. This endpoint accepts the same request body as the results endpoint.
Response:

2. Retrieve the dataCode with the SharedToken

Send a POST request to the Request experiment’s results endpoint using the SharedToken from the previous response in place of an access token.
Response:

2. Retrieve the experiment results

After receiving the dataCode from either case above, call the result endpoint.
If the response returns "status": "WAITING", the report is still generating. Retry the request after a short delay until the status is "READY".
Response:

3. Interpreting the results to determine the winning variation

Winning variations must demonstrate high reliability (exceeding 95%) and a positive improvement rate compared to the reference variation. The JSON response shows that both Redesign 1 and Redesign 2 have a 100% reliability rate. However, Redesign 1 has a +211.48% improvement rate compared to the -43.33% rate of Redesign 2. Therefore, Redesign 1 is the winner. Redesign 1
Redesign 2

4. Filter experiment results

Obtain specific results by using the breakdown and filters parameters. The breakdown parameter organizes data by a single dimension (such as browser, operating system, or day of the week). The filters parameter restricts data to a subset of visitors before the breakdown is applied.
The breakdown parameter accepts a single object per request, not an array. To compare several dimensions, send one request per breakdown.

Breakdown formats

Most breakdown types take only a type field, for example:
Three breakdown types require additional fields: INTERVAL — segments results by a time interval. Pair "type": "INTERVAL" with an interval field:
The interval field accepts HOUR, DAY, WEEK, MONTH, or YEAR. CUSTOM_DATUM — segments results by custom data index. Pair "type": "CUSTOM_DATUM" with an index field:
CROSS_CAMPAIGN — segments results by exposure to another experiment or personalization. Provide at least one of experiments or personalizations:

Filter types

Each filter object requires a type string and an include boolean. Set include to true to restrict results to matching visitors, or false to exclude them. The additional fields depend on type:

Example: browser breakdown filtered to new visitors

The following request applies a browser breakdown restricted to new visitors by sending a POST to the Request experiment’s results endpoint:
After receiving the dataCode, retrieve the results:
A successful response returns results broken down by browser. The response follows the same structure as step 2 above, with each browser type (CHROME, FIREFOX, OTHERS, etc.) as a key within breakdownData. The following response is truncated for clarity: