It’s recommended to use the Kotlin API client, which is better suited for Android development.
The region
A/B testing is specific to a region. As such, you should use the region where your analytics data is stored and processed. View your analytics region.
1
2
3
4
5
6
7
8
9
10
11
12
13
| use Algolia\AlgoliaSearch\AnalyticsClient;
$analytics = AnalyticsClient::create(
'YourApplicationID',
'YourAdminAPIKey',
'de' // Defaults to "us"
);
$abTest = [
// The A/B test
];
$response = $analytics->addABTest($abTest);
|
1
2
3
4
5
6
7
| analytics = Algolia::Analytics::Client.create('YourApplicationID', 'YourAdminAPIKey')
ab_test = {
# The A/B test
}
analytics.add_ab_test(ab_test)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const analytics = client.initAnalytics({
region: 'de' // defaults to 'us'
appId: 'YourApplicationID',
apiKey: 'YourAdminAPIKey',
});
const abTest = {
/** The A/B test */
};
analytics.addABTest(abTest).then(({ abTestID }) => {
console.log(abTestID);
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| from algoliasearch.analytics_client import AnalyticsClient
analytics = AnalyticsClient.create(
'YourApplicationID',
'YourAdminAPIKey',
'de' # defaults to 'us'
)
ab_test = {
# The A/B test
}
response = analytics.add_ab_test(ab_test)
|
1
2
3
4
5
6
7
8
9
10
11
| let client = AnalyticsClient(appID: "YourApplicationID",
apiKey: "YourAdminAPIKey",
region: .de /* Defaults to region.US */)
let abTest: ABTest /* The AB test */
client.addABTest(abTest) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
|
1
2
3
4
5
6
7
8
9
| var client = new AnalyticsClient(
"YourApplicationID",
"YourAdminAPIKey",
"de", // Defaults to "us"
);
var abTest = new ABTest( /* The AB test */ );
var res = client.AddABTest(abTest);
|
1
2
3
4
5
6
7
8
9
| AnalyticsClient client =
DefaultAnalyticsClient.create(
"YourApplicationID",
"YourAdminAPIKey",
"de"); // Defaults to "us"
ABTest abtest = new ABTest( /* The AB test */ );
AddABTestResponse res = client.addABTest(abtest);
|
1
2
3
4
5
6
7
8
9
10
11
| client := analytics.NewClientWithConfig(
analytics.Configuration{
AppID: "YourApplicationID",
APIKey: "YourAdminAPIKey",
Region: region.DE, // Defaults to region.US
},
)
abTest := analytics.ABTest{ /* The AB test */ }
res, err := client.AddABTest(abTest)
|
1
| This method is not yet available in the Scala API client.
|
1
| This method is not yet available in the Kotlin API client.
|