As of December 31, 2023, Shopify no longer allows apps to modify theme code.
To integrate Autocomplete and InstantSearch, use the Algolia AI Search & Discovery app’s App Embed and App Blocks.
To get started, see Quickstart and Algolia configuration.
- Search analytics
- Revenue analytics
- A/B Testing
- NeuralSearch
- Algolia Recommend
- Personalization
- Dynamic Re-Ranking
- Query Categorization
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. Algolia Search must be enabled on your theme, to get started, see Enable Algolia 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.

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, you can 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.

Shopify web pixels
Shopify web pixels are JavaScript snippets that you can install in your Shopify store to 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.To capture events with web pixels,
enable the app embed for Algolia Search.
If you are using web pixels with a custom frontend,
ensure you also call
algoliaShopify.helpers.handleItemClick(hitObject)
from your Autocomplete and InstantSearch product templates.
This step ensures that the web pixel can capture conversion events from items in the browser’s local storage.Explore related content in the Algolia Academy
Shopify web pixel
Install Shopify web pixels
- Go to your Shopify admin and click Settings.
-
Open the Customer events tab.
-
Click Add custom pixel.
-
Name your pixel and click Add pixel.
-
Copy the pixel code and paste it into the Algolia web pixels area in the Code section provided by Shopify.
JavaScript
-
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.
-
Go back to your Shopify admin and complete the setup by clicking Activate & Continue.
Custom frontends with Shopify web pixels
If you want to use Shopify web pixels with your custom frontend, passquery_id
, variant_id
, and product_id
to the trackSearchAttribution
function.
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.
- User searches and then clicks a result.
-
The
trackSearchAttribution
function storesqueryId
,variantId
, andproductId
in local storage. -
The Shopify web pixel
product_added_to_cart
event is triggered. -
The
trackSearchAttribution
function is called withquery_id
,variant_id
, andproduct_id
. -
Algolia retrieves the
queryId
by matching thevariantId
andproductId
in local storage. -
Algolia sends attribution data to the index:
- If
queryId
is specified, Algolia uses theaddedToCartObjectIDsAfterSearch
event. - If
queryId
isn’t specified, Algolia uses theaddedToCartObjectIDs
event.
- If