> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get A/B test

> Get an A/B test information and results.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Retrieve A/B test details" href="/doc/libraries/sdk/methods/abtesting/get-ab-test" />

**Required ACL:** `analytics`

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  AnalyticsClient analytics = new AnalyticsClient("YourApplicationID", "YourWriteAPIKey");
  ABTest abtest = analytics.GetABTest(42);
  ```

  ```go Go theme={"system"}
  client := analytics.NewClient("YourApplicationID", "YourWriteAPIKey")
  res, err := client.GetABTest(42)
  ```

  ```java Java theme={"system"}
  AnalyticsClient analytics =
  DefaultAnalyticsClient.create("YourApplicationID", "YourWriteAPIKey");

  ABTest abtest = analytics.getABTest(42);

  // Asynchronous
  CompletableFuture<ABTes>t abtest = analytics.getABTestAsync(42);
  ```

  ```js JavaScript theme={"system"}
  const analytics = client.initAnalytics({
    // optional parameters
    region: "de",
    appId: "YourApplicationID",
    apiKey: "YourWriteAPIKey",
  });
  analytics.getABTest(42).then((abTest) => {
    console.log(abTest);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  clientAnalytics.getABTest(ABTestID(42))
  ```

  ```php PHP theme={"system"}
  $analytics = AnalyticsClient::create(
    'YourApplicationID',
    'YourWriteAPIKey'
  );

  $analytics->getABTest(42);
  ```

  ```python Python theme={"system"}
  analytics = AnalyticsClient.create("YourApplicationID", "YourWriteAPIKey")

  analytics.get_ab_test(42)
  ```

  ```ruby Ruby theme={"system"}
  analytics = Algolia::Analytics::Client.create("YourApplicationID", "YourWriteAPIKey")
  analytics.get_ab_test(42)
  ```

  ```scala Scala theme={"system"}
  client.execute {
    get abTest 42
  }
  ```

  ```swift Swift theme={"system"}
  analyticsClient.getABTest(withID: 42) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="abTestID" type="integer" required>
  Unique identifier of the A/B test.
</ParamField>

## Response

<ResponseField name="abTestID" type="integer">
  Unique identifier of the A/B test.
</ResponseField>

<ResponseField name="addToCartSignificance" type="number">
  A/B test significance based on `addToCart` conversions.
  Should be greater than 0.95 to be considered significant,
  no matter which variant is winning.
</ResponseField>

<ResponseField name="clickSignificance" type="number">
  A/B test significance based on click data.
  Should be greater than 0.95 to be considered significant,
  no matter which variant is winning.
</ResponseField>

<ResponseField name="configuration" type="object">
  Configuration parameters for the A/B test.

  <Expandable>
    <ResponseField name="emptySearch" type="object">
      <Expandable>
        <ResponseField name="exclude" type="boolean">
          Whether empty searches are excluded when calculating A/B test results.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="outliers" type="object">
      <Expandable>
        <ResponseField name="exclude" type="boolean">
          Whether outliers are excluded when calculating A/B test results.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="conversionSignificance" type="number">
  A/B test significance based on conversion data.
  Should be greater than 0.95 to be considered significant,
  no matter which variant is winning.
</ResponseField>

<ResponseField name="createdAt" type="string">
  Time at which the A/B test has been created.
  **Format:** `Y-m-d\TH:i:s\Z`
</ResponseField>

<ResponseField name="endAt" type="string">
  Time at which the A/B test will automatically stop.
  **Format:** `Y-m-d\TH:i:s\Z`
</ResponseField>

<ResponseField name="name" type="string">
  Name of the A/B test.
</ResponseField>

<ResponseField name="purchaseSignificance" type="number">
  A/B test significance based on `purchase` conversions.
  Should be greater than 0.95 to be considered significant,
  no matter which variant is winning.
</ResponseField>

<ResponseField name="revenueSignificance" type="object">
  A/B test revenue significance for each currency.
  This object has currency codes as keys and the significance scores as values.
</ResponseField>

<ResponseField name="status" type="string">
  Current status of the A/B test.
</ResponseField>

<ResponseField name="variants" type="object[]">
  The two A/B test variants:

  * The base index
  * The index to test against

  <Expandable>
    <ResponseField name="addToCartCount" type="integer">
      Distinct number of converted clicks with the `eventSubtype` set to `addToCart` and `clickAnalytics` set to `true`.
    </ResponseField>

    <ResponseField name="addToCartRate" type="number">
      Add-to-cart rate is based on conversion events that have [`eventSubType`](/doc/rest-api/insights) set to `addToCart`, and the total number of
      tracked searches within the specified timeframe. The rates are computed as the number of add-to-cart conversion events divided by the
      number of tracked searches.
    </ResponseField>

    <ResponseField name="averageClickPosition" type="integer">
      Average click position for the variant.
    </ResponseField>

    <ResponseField name="clickCount" type="integer">
      Distinct click count for the variant.
    </ResponseField>

    <ResponseField name="clickThroughRate" type="number">
      Click through rate for the variant.
    </ResponseField>

    <ResponseField name="conversionCount" type="integer">
      Distinct conversion count for the variant.
    </ResponseField>

    <ResponseField name="conversionRate" type="number">
      Conversion rate for the variant.
    </ResponseField>

    <ResponseField name="currencies" type="object">
      Revenue metrics for each currency.
      Each key is a [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) currency code.
      Each value is an object with these properties:

      <Expandable>
        <ResponseField name="currency" type="string">
          Currency code in ISO 4217 format.
        </ResponseField>

        <ResponseField name="mean" type="number">
          Mean revenue for this currency.
        </ResponseField>

        <ResponseField name="revenue" type="number">
          Revenue made in this currency.
        </ResponseField>

        <ResponseField name="standardDeviation" type="number">
          Standard deviation for the revenue made in this currency.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="description" type="string">
      Description of the variant.
    </ResponseField>

    <ResponseField name="filterEffects" type="object">
      Effects of the outlier or empty search exclusion.
      Each effect has these properties:

      * `usersCount`: number of users excluded by this filter
      * `trackedSearchesCount`: number of tracked searches excluded by this filter

      **Example:**

      ```jsonc JSON icon=braces theme={"system"}
      {
        "outliers": {
              "usersCount": "...",
              "trackedSearchesCount": "..."
        },
        "emptySearch": {
              "usersCount": "...",
              "trackedSearchesCount": "..."
          }
      }
      ```
    </ResponseField>

    <ResponseField name="index" type="string">
      Index name of the variant.
    </ResponseField>

    <ResponseField name="noResultCount" type="integer">
      Number of tracked searches without any results.
    </ResponseField>

    <ResponseField name="purchaseCount" type="integer">
      Distinct number of converted clicks with the `eventSubtype` set to `purchase` and `clickAnalytics` set to `true`.
    </ResponseField>

    <ResponseField name="purchaseRate" type="number">
      The purchase rate is based on conversion events with the [`eventSubType`](/doc/rest-api/insights) set to `purchase`,
      and the total number of tracked searches within the specified timeframe.
      The rates are computed as the number of purchase conversion events divided by the number of tracked searches.
    </ResponseField>

    <ResponseField name="searchCount" type="integer">
      Total number of searches for this variant, including untracked searches.
    </ResponseField>

    <ResponseField name="trackedSearchCount" type="integer">
      Number of tracked searches for this variant.
      Tracked searches are searches with [`clickAnalytics`](/doc/api-reference/api-parameters/clickAnalytics) enabled.
    </ResponseField>

    <ResponseField name="trackedUserCount" type="integer">
      Number of users who searched this variant with at least one search that had [`clickAnalytics`](/doc/api-reference/api-parameters/clickAnalytics) enabled.
    </ResponseField>

    <ResponseField name="userCount" type="integer">
      Total number of users who searched on this variant, including untracked users.
    </ResponseField>
  </Expandable>
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "abTestID": 78,
  "clickSignificance": 1,
  "conversionSignificance": 0.9937,
  "createdAt": "2018-05-15T17:52:15.644906Z",
  "endAt": "2018-05-17T23:59:59Z",
  "name": "Custom Ranking salesRank Test",
  "status": "stopped",
  "configuration": {
    "outliers": {
      "exclude": true
    }
  },
  "variants": [
    {
      "averageClickPosition": 0,
      "clickCount": 17115,
      "clickThroughRate": 0.19839107906664039,
      "conversionCount": 11508,
      "conversionRate": 0.13339670101658765,
      "description": "",
      "index": "atis-abtest-default",
      "noResultCount": 0,
      "searchCount": 86269,
      "trackedSearchCount": 70365,
      "trafficPercentage": 70,
      "userCount": 55501,
      "trackedUserCount": 44197,
      "filterEffects": {
          "outliers": {
            "usersCount": 0,
            "trackedSearchesCount": 0
          }
       }
    },
    {
      "averageClickPosition": 0,
      "clickCount": 7716,
      "clickThroughRate": 0.20869847452125934,
      "conversionCount": 5129,
      "conversionRate": 0.13872660391647734,
      "description": "",
      "index": "atis-abtest-salesRank",
      "noResultCount": 0,
      "searchCount": 36972,
      "trackedSearchCount": 30459,
      "trafficPercentage": 30,
      "userCount": 22694,
      "trackedUserCount": 21356,
      "filterEffects": {
          "outliers": {
            "usersCount": 1,
            "trackedSearchesCount": 300
          }
       }
    }
  ]
}
```
