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

# Algolia

> Build, power, and optimize digital experiences

## Overview

You want to provide relevant search and discovery results and doing so heavily relies on data in your Algolia account to be accurate and fresh. By automatically indexing records and events from your data warehouse into Algolia, you no longer need to worry about data consistency because data is no longer flowing in from multiple sources in different formats, and you can focus on building world-class customer experiences.

## Supported syncing

| Type | Description | Supported Sync Modes |
| - | - | - |
| **Index records** | Sync data from any source to indices in Algolia | Upsert, Update, Insert |
| **Insight events** | Sync data from any source to insight events in Algolia | Insert |

For more information about sync modes, refer to the [sync modes](https://docs.hightouch.com/syncs/types-and-modes.md#sync-modes) docs.

## Connect to Algolia

Go to the [**Destinations** overview page](https://app.hightouch.com/destinations?from=docs) and click the **Add destination**
button. Select **Algolia** and click **Continue**. You can then authenticate Hightouch to **Algolia** with an API key.

Enter the following required fields into Hightouch:

* **Application ID**
* **API Key**

Follow [these instructions](https://www.algolia.com/doc/guides/security/api-keys/#creating-and-managing-api-keys) to create your API key and provide at least these [permissions](https://www.algolia.com/doc/guides/security/api-keys/#rights-and-restrictions):

| Permissions | Required? |
| - | - |
| **listIndexes** | YES |
| **addObject** | YES |
| **deleteObject** | If you choose to [delete records](#delete-behavior) |

## Sync configuration

Once you've set up your Algolia destination and have a [model](https://docs.hightouch.com/getting-started/concepts.md#models) to pull
data from, you can set up your sync configuration to begin syncing data. Go to the [**Syncs** overview
page](https://app.hightouch.com/syncs?from=docs) and click the **Add sync** button to begin. Then, select the relevant model and
the Algolia destination you want to sync to.

### Indices

An [Algolia index](https://support.algolia.com/hc/en-us/articles/4406981910289-What-is-an-index-) is the place where the data used by a search engine is stored. You can use Hightouch to update individual records in an index.

#### Record matching

You must match rows in your model with objects in Algolia on the [**Object ID** field](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/#using-unique-object-identifiers).

> [!NOTE]
>
> In **Insert** mode, Algolia automatically generates a **Object ID** for every new record synced, so there is no need to match an existing record.

#### Field mapping

Records in Algolia index don't need to follow a schema so you can sync any custom fields to them.

Visit Algolia's docs for more information about [Algolia records](https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data/#algolia-records).

#### Delete behavior

**Clear** is only available for update mode. **Delete** is only available for upsert mode. All sync modes use the **Do nothing** behavior by default.

| Behavior | Description |
| - | - |
| **Do nothing** | Keep the customer record in Algolia with all its synced fields |
| **Clear** | Unset all the mapped fields from Algolia |
| **Delete** | Delete the synced record from your Algolia index. Your [API key needs the **deleteObject** ACL](#connect-to-algolia) to enable this |

### Insight events

Insights events lets you capture click, conversion, and view events to help you understand how your users interact with your digital experience.

#### Field mapping

When syncing insight events to Algolia, you must provide the following fields:

* **Event Name**: Name of the event. Typically the action performed.
* **Event Type**: Type of the event. The allowed values are `"click"`, `"conversion"`, or `"view"`.
* **Index**: Name of the targeted index.
* **User Token**: A user identifier. Depending if the user is logged-in or not, several strategies can be used from a `sessionId` to another technical identifier. You should always send pseudonymous or anonymous userTokens.

YOu can also provide these optional fields:

* **Timestamp**: Time of the event expressed in milliseconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time).
* **Query ID**: Algolia `queryID`. This is required when an event is tied to a search.
* **Object IDs**: An array of index `objectIDs`. Limited to 20 objects. An event can't have both `objectIDs` and filters at the same time.
* **Filters**: An array of filters. Limited to 10 filters. An event can't have both `objectIDs` and filters at the same time.
* **Positions**: Position of the click in the list of Algolia search results. This field is required if a `queryID` is provided. One position must be provided for each `objectID`.

> [!NOTE]
>
> When an event is tied to an Algolia search, it must also provide a queryID. If that event is a click, their absolute positions should also be passed. Consult [Algolia's documentation](https://www.algolia.com/doc/api-reference/api-methods/send-events/#parameters) for more information on event fields.

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).
