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
import { algoliasearch } from 'algoliasearch';

// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });

const response = await client.estimateABTest({
  configuration: {
    emptySearch: { exclude: true },
    minimumDetectableEffect: { size: 0.03, metric: 'conversionRate' },
  },
  variants: [
    { index: 'AB_TEST_1', trafficPercentage: 50 },
    { index: 'AB_TEST_2', trafficPercentage: 50 },
  ],
});
Did you find this page helpful?