analytics
Usage
// Initialize the client
var client = new AbtestingClient(
new AbtestingConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.EstimateABTestAsync(
new EstimateABTestRequest
{
Configuration = new EstimateConfiguration
{
EmptySearch = new EmptySearch { Exclude = true },
MinimumDetectableEffect = new MinimumDetectableEffect
{
Size = 0.03,
Metric = Enum.Parse<EffectMetric>("ConversionRate"),
},
},
Variants = new List<AddABTestsVariant>
{
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 50 }),
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50 }),
},
}
);
// print the response
Console.WriteLine(response);
// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION
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)
}
// Call the API
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)
}
// print the response
print(response)
// Initialize the client
AbtestingClient client = new AbtestingClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
EstimateABTestResponse response = client.estimateABTest(
new EstimateABTestRequest()
.setConfiguration(
new EstimateConfiguration()
.setEmptySearch(new EmptySearch().setExclude(true))
.setMinimumDetectableEffect(new MinimumDetectableEffect().setSize(0.03).setMetric(EffectMetric.CONVERSION_RATE))
)
.setVariants(
Arrays.asList(
new AbTestsVariant().setIndex("AB_TEST_1").setTrafficPercentage(50),
new AbTestsVariant().setIndex("AB_TEST_2").setTrafficPercentage(50)
)
)
);
// print the response
System.out.println(response);
// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });
// Call the API
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 },
],
});
// print the response
console.log(response);
// Initialize the client
val client =
AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.estimateABTest(
estimateABTestRequest =
EstimateABTestRequest(
configuration =
EstimateConfiguration(
emptySearch = EmptySearch(exclude = true),
minimumDetectableEffect =
MinimumDetectableEffect(
size = 0.03,
metric = EffectMetric.entries.first { it.value == "conversionRate" },
),
),
variants =
listOf(
AbTestsVariant(index = "AB_TEST_1", trafficPercentage = 50),
AbTestsVariant(index = "AB_TEST_2", trafficPercentage = 50),
),
)
)
// print the response
println(response)
// Initialize the client
$client = AbtestingClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
// Call the API
$response = $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,
],
],
],
);
// print the response
var_dump($response);
# Initialize the client
# In an asynchronous context, you can use AbtestingClient instead, which exposes the exact same methods.
client = AbtestingClientSync(
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)
# Call the API
response = client.estimate_ab_test(
estimate_ab_test_request={
"configuration": {
"emptySearch": {
"exclude": True,
},
"minimumDetectableEffect": {
"size": 0.03,
"metric": "conversionRate",
},
},
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 50,
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50,
},
],
},
)
# print the response
print(response)
# Initialize the client
client = Algolia::AbtestingClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
# Call the API
response = client.estimate_ab_test(
Algolia::Abtesting::EstimateABTestRequest.new(
configuration: Algolia::Abtesting::EstimateConfiguration.new(
empty_search: Algolia::Abtesting::EmptySearch.new(exclude: true),
minimum_detectable_effect: Algolia::Abtesting::MinimumDetectableEffect.new(size: 0.03, metric: "conversionRate")
),
variants: [
Algolia::Abtesting::AbTestsVariant.new(index: "AB_TEST_1", traffic_percentage: 50),
Algolia::Abtesting::AbTestsVariant.new(index: "AB_TEST_2", traffic_percentage: 50)
]
)
)
# print the response
puts(response)
// Initialize the client
val client = AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = Option("ALGOLIA_APPLICATION_REGION")
)
// Call the API
val response = Await.result(
client.estimateABTest(
estimateABTestRequest = EstimateABTestRequest(
configuration = EstimateConfiguration(
emptySearch = Some(
EmptySearch(
exclude = Some(true)
)
),
minimumDetectableEffect = MinimumDetectableEffect(
size = 0.03,
metric = EffectMetric.withName("conversionRate")
)
),
variants = Seq(
AbTestsVariant(
index = "AB_TEST_1",
trafficPercentage = 50
),
AbTestsVariant(
index = "AB_TEST_2",
trafficPercentage = 50
)
)
)
),
Duration(100, "sec")
)
// print the response
println(response)
// Initialize the client
let client = try AbtestingClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
// Call the API
let response = try await client.estimateABTest(estimateABTestRequest: AbtestingEstimateABTestRequest(
configuration: AbtestingEstimateConfiguration(
emptySearch: EmptySearch(exclude: true),
minimumDetectableEffect: AbtestingMinimumDetectableEffect(
size: 0.03,
metric: AbtestingEffectMetric.conversionRate
)
),
variants: [
AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(
index: "AB_TEST_1",
trafficPercentage: 50
)),
AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(
index: "AB_TEST_2",
trafficPercentage: 50
)),
]
))
// print the response
print(response)
See the full API reference
For more details about input parameters
and response fields.