Skip to main content
The Algolia AI Search & Discovery app lets you track click and conversion events from your Shopify store. Sending events enables you to use these features:

Before you begin

Algolia AI Search & Discovery supports the default widgets provided by the app. If you’re using custom widgets, see Sending events for more information. The Algolia AI Search & Discovery app must be enabled on your theme.

User token strategy

Events represent an interaction of a user with your store. Algolia relates a user profile to an event through a user token. You can choose how you want to set the user token:
  • With a random alphanumeric string at every page refresh
  • Using cookies

userToken is set with a random alphanumeric string at every page refresh

This option doesn’t use cookies. Because every page refresh generates a new user token, you can’t identify user profiles across sessions.

userToken is set using cookies depending on the user’s approval

This option stores the user token in a cookie on the user’s device. You must use Shopify’s Customer Privacy API or enable Shopify’s Cookie Consent Banner in your Shopify admin settings. Screenshot of a 'Cookie banner' settings page with a privacy message, 'Accept' and 'Decline' buttons, and 'Bottom center' position selected. If the user hasn’t consented, a random alphanumeric string is used as user token. Algolia uses Shopify’s loadFeatures method to check if the user has consented.

User token for Personalization

To personalize your search experience, you need to provide a way to identify user profiles across sessions with a stable user token. For example, you can use the user’s account ID after they signed in to your shop. To add a stable user token, use custom hooks.

Send events

To track user interactions in your Shopify store and send them to Algolia, choose between:
  • Use Essentials Analytics: automatically send “click”, “view”, and “search” events to Algolia.
  • Use Conversion Analytics: using Shopify web pixels, send “addToCart” and “purchase” conversion events to Algolia.
Screenshot of the 'Send events' section with analytics options and a 'Save' button.

Shopify web pixels

Shopify web pixels are JavaScript snippets that track user interactions and improve your search results. The web pixels collect data about your users’ interactions with your store, such as add-to-cart and purchase events. You can use the data to improve the relevance of your search results and gain insights into your users’ behavior. By default, the Algolia AI Search & Discovery app creates and enables a web pixel to collect event data. To capture events with web pixels, enable the app embed for Algolia Search. If you’re using web pixels with a custom frontend, ensure you also call trackSearchAttribution(hit) from your Autocomplete and InstantSearch product templates. This ensures the web pixel can capture conversion events from items in the browser’s local storage. For more information, see Custom frontends with Shopify web pixels.
The Shopify web pixel is categorized as “analytics” and “preferences”, according to Shopify’s criteria. It collects data only if users accept the consent banner.To stop the pixel from collecting data, in Shopify Admin Settings, turn off Use Conversion Analytics.

Install a Custom Shopify web pixel

  1. Go to your Shopify admin and click Settings.
  2. Open the Customer events tab. Screenshot of the 'Customer events' page in Shopify, showing the 'Add custom pixel' button and a graphic illustrating pixel management.
  3. Click Add custom pixel. Screenshot of a Shopify pixels page with 'Explore pixel apps' and 'Add custom pixel' buttons.
  4. Name your pixel and click Add pixel. Screenshot of a dialog box titled 'Add custom pixel' with a 'Pixel name' field containing 'Algolia Shopify Web Pixel' and an 'Add pixel' button.
  5. Copy the pixel code and paste it into the Algolia web pixels area in the Code section provided by Shopify.
    JavaScript
  6. Click Save, then Connect. Your Shopify web pixels are now installed and can start tracking user interactions on your store. Make sure that your web pixels show Connected in their status. Screenshot of a table showing 'Algolia Shopify Web Pixel' as a custom pixel with a 'Connected' status in a green badge.
  7. Go back to your Shopify admin and complete the setup by clicking Activate & Continue. Screenshot of a dialog box titled 'Boost Your Relevance with Conversion Analytics' with a blue 'Activate and Continue' button.

Custom frontends with Shopify web pixels

If you want to use Shopify web pixels with your custom frontend, pass query_id, variant_id, and product_id to the trackSearchAttribution function. Add the following JavaScript to your custom frontend to call trackSearchAttribution whenever a hit is displayed. This stores the required attributes in localStorage for conversion tracking.
JavaScript

Web pixel product_added_to_cart flow

This process shows how a Shopify web pixel product_added_to_cart event is sent to Algolia.
  1. User searches and then clicks a result.
  2. The trackSearchAttribution function stores queryId, variantId, and productId in local storage.
  3. The Shopify web pixel product_added_to_cart event is triggered.
  4. The trackSearchAttribution function is called with query_id, variant_id, and product_id.
  5. Algolia retrieves the queryId by matching the variantId and productId in local storage.
  6. Algolia sends attribution data to the :
Last modified on June 19, 2026