Check your events
Check that your click and conversion events are valid and usable for A/B testing. For more information, see Validate your events. If you use Revenue Analytics, send conversion events witheventSubtype set to purchase for purchases or addToCart when users add items to their cart.
For revenue metrics, include the price and quantity of each purchased item and the currency.
This feature isn’t available on every plan.
Refer to your pricing plan to see if it’s included.
Identify your users
Assign each user a unique, stableuserToken.
Use the same token for their searches and click and conversion events.
Send the token with the userToken search parameter or the X-Algolia-UserToken request header.
Algolia uses this token to assign users to A/B test variants.
Keep it consistent across search sessions so users stay in the same variant.
If you don’t provide a user token, Algolia uses the request’s IP address.
Create a user token in your app instead of relying on IP addresses, which users can share.
Don’t include personally identifiable information in user tokens.
Identify users in backend searches
If you use backend search, include each user’suserToken in the requests you forward to Algolia.
Without a user token or a forwarded user IP address,
Algolia treats searches from the same server IP address as searches from one user.
If you can’t provide a user token,
forward the user’s IP address with the X-Forwarded-For header.
Check your Personalization implementation
If you use Personalization, check your setup on the Personalization implementation help page in the Algolia dashboard. Send the sameuserToken with searches and click and conversion events.
This feature isn’t available on every plan.
Refer to your pricing plan to see if it’s included.
Handle anonymous users
If each anonymous user has a unique token that stays the same across search sessions, include them in your A/B test. Don’t exclude users solely because they aren’t signed in. If users share a token, Algolia treats them as one user. If you can’t provide a unique, stable token, exclude those searches from A/B testing by settingenableABTest to false.
The following example checks for a missing or anonymous user token (null, undefined, or YOUR_ANONYMOUS_USER_TOKEN).
It sets enableABTest to false for those search requests.
Exclude internal searches
Exclude searches from internal dashboards, testing tools, and administrative pages by settingenableABTest to false.
Avoid overrides of A/B test settings
Don’t send search parameters that override the settings you’re comparing in an A/B test. For example, to compare results with and without Personalization, turn it off for variant A and on for variant B. Don’t sendenablePersonalization: true with every search request.
Otherwise, both variants can use Personalization, so the test doesn’t measure the effect of turning it on.
Manage bot traffic
Bot-generated searches can distort and other test metrics. Although Algolia excludes outlier users when calculating A/B test results, this filtering doesn’t necessarily block bot searches. To reduce bot traffic:- Set rate limits. Configure API key rate limits to restrict search requests.
- Restrict HTTP referrers. Allow only expected referrers for your API keys. Don’t rely on this restriction alone to block bots because clients can spoof the
Refererheader. - Configure
robots.txt. Disallow crawling of your search pages. These rules apply only to bots that respectrobots.txt.