> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prepare your environment for A/B testing

> How to prepare your environment for A/B test.

export const AcademyLink = ({href, title}) => {
  return <Card horizontal title="Algolia Academy" href={href} icon="square-play">Learn more about: {title}</Card>;
};

A couple of steps will help you prepare your A/B testing environment.

## Set up click analytics

To enable Algolia A/B testing,
you need to send [click and conversion events](/doc/guides/sending-events/getting-started).

The Revenue Analytics feature includes sending `purchase` and `addToCart` conversion events.

<Callout icon="credit-card" color="#c084fc">
  This feature isn't available on every plan.
  Refer to your [pricing plan](https://www.algolia.com/pricing) to see if it's included.
</Callout>

## Add unique user identifiers to your searches

Make sure every search is associated with a **unique user identifier**.
This serves two purposes:

* **Guarantees consistent variant assignment.** Algolia assigns each new user to a variant based on their user ID. This assignment is stable as long as the same user ID is provided for subsequent search sessions.
* **Ensures distribution integrity.** Users remain in their assigned variant, which helps ensure reliable test results.

Algolia uses unique user tokens to ensure that the same user is always directed to the same variant.
By default, [the user token is the user's IP address](/doc/guides/search-analytics/guides/usertoken).
However, it's better to explicitly create a unique user identifier that you can keep track of in your own application.
The user identifier can be sent to Algolia with the [`userToken`](/doc/api-reference/api-parameters/userToken) parameter,
or with the `X-Algolia-UserToken` request header.

## A/B testing

After completing these steps,
[follow the dashboard's process to start, stop, and view your tests](/doc/guides/ab-testing/what-is-ab-testing/how-to/create-and-run-an-ab-test).

If you want to A/B test different settings for the same index in the dashboard,
select the same index for both variants.
