> ## 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 event implementation

> Learn how to prepare your event implementation for Advanced Personalization.

After [preparing your index](/doc/guides/personalization/advanced-personalization/configure/prerequisites/index-structure),
set up the events required for Advanced Personalization.

To enable Advanced Personalization, send events that reflect how users interact with your website or app.
For an overview of the available implementation options, see [Choose how to send events](/doc/guides/sending-events/getting-started).

<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>

## Attach user tokens to events

Advanced Personalization builds user profiles from click and conversion events identified by the [`userToken`](/doc/guides/sending-events/concepts/usertoken) property.
To build and retrieve user profiles:

* Attach a user token to each event so Algolia can associate events with the same user over time.
* Persist [anonymous user tokens](/doc/guides/sending-events/concepts/usertoken#persistent-user-token) and authenticated user tokens across sessions so you can retrieve user profiles at search time.

If you use Algolia's UI libraries, see [Set the user token in InstantSearch and Autocomplete](/doc/guides/search-analytics/guides/usertoken#set-the-user-token-in-instantsearch-and-autocomplete).

If you send events with an API client, use the Search Insights library's [`setUserToken`](/doc/libraries/search-insights/set-user-token) method.
You can either set a global user token or send a user token with an individual event:

<Tabs>
  <Tab title="Set a global user token">
    ```js JavaScript icon=code theme={"system"}
    // Set a global user token
    aa('setUserToken', 'user-1');

    // Send a click event associated with "user-1"
    aa('clickedObjectIDs', {
        index: 'movies',
        eventName: 'Added to favorite',
        objectIDs: ['movieID1'],
    });
    ```
  </Tab>

  <Tab title="Send a user token with a specific event">
    ```js JavaScript icon=code theme={"system"}
    // Send a click event associated with "user-2"
    aa('clickedObjectIDs', {
        userToken: 'user-2',
        index: 'movies',
        eventName: 'Added to favorite',
        objectIDs: ['movieID1'],
    });
    ```
  </Tab>
</Tabs>

For more information, see [Distinguish users for analytics](/doc/guides/search-analytics/guides/usertoken).

## Event properties

To contribute to Advanced Personalization, events must reference records in an existing index.

* Link events to an existing index. Algolia ignores events whose `objectID` values don't match records in the index when computing user profiles.
* Events without a `queryID` still contribute to personalization but Algolia doesn't report them in search analytics.
* You can send events in batches but each event timestamp should reflect *when* you collected the event.

## Send conversion events with subtypes

Conversion events help enrich user profiles for Advanced Personalization.
When users convert,
send a `conversion` event with the appropriate subtype:

* When a user adds an item to their cart, send a conversion event with the [`addToCart` subtype and associated `objectData`](/doc/libraries/sdk/v1/methods/added-to-cart-object-ids).
* When a user purchases an item, send a conversion event with the [`purchase` subtype and associated `objectData`](/doc/libraries/sdk/v1/methods/purchased-object-ids).

## Check your events implementation

1. Visit your website and interact with it to generate events.
2. In the Algolia dashboard, check the [**Events debugger**](https://dashboard.algolia.com/events/hub) to confirm that Algolia receives your events.

## See also

* [Google Analytics BigQuery export](/doc/guides/sending-events/connectors/google-analytics-big-query-export)
