Estimate the sample size and duration of an A/B test

Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic.

Usage

Required ACL: analytics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import "github.com/algolia/algoliasearch-client-go/v4/algolia/abtesting"

client, err := abtesting.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", abtesting.US)
if err != nil {
  // The client can fail to initialize if you pass an invalid parameter.
  panic(err)
}

response, err := client.EstimateABTest(client.NewApiEstimateABTestRequest(

  abtesting.NewEmptyEstimateABTestRequest().SetConfiguration(
    abtesting.NewEmptyEstimateConfiguration().SetEmptySearch(
      abtesting.NewEmptyEmptySearch().SetExclude(true)).SetMinimumDetectableEffect(
      abtesting.NewEmptyMinimumDetectableEffect().SetSize(0.03).SetMetric(abtesting.EffectMetric("conversionRate")))).SetVariants(
    []abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(
      abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_1").SetTrafficPercentage(50)), *abtesting.AbTestsVariantAsAddABTestsVariant(
      abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_2").SetTrafficPercentage(50))})))
if err != nil {
  // handle the eventual error
  panic(err)
}
Did you find this page helpful?