Shopify Algolia global events
Since December 31, 2023, apps can’t modify the code of Shopify themes. For more information, see The Asset API resource in the Shopify documentation. As an alternative, the Algolia AI Search and Discovery app comes with Shopify App Embed and App Blocks to integrate Autocomplete and InstantSearch. To get started, see Quickstart and Algolia configuration.
The global events algolia.instantsearch.hitClickAction
and algolia.autocomplete.hitClickAction
will be deprecated from March 31, 2025. Use the beforeInstantSearchProductTemplate
and beforeAutocompleteProductTemplate
events instead.
The InstantSearch and Autocomplete libraries emit global events. You can’t pass data to the global events but you can listen to them.
algolia.autocomplete.beforeInit
is emitted before the Autocomplete library is initializedalgolia.autocomplete.afterInit
is emitted after the Autocomplete library is initializedalgolia.autocomplete.hitClickAction
is emitted when a user clicks on an Autocomplete result- Deprecated from March 31, 2025.
- Use
beforeAutocompleteProductTemplate
for adding click events.
algolia.instantsearch.beforeInit
is emitted before the InstantSearch library is initializedalgolia.instantSearch.afterInit
is emitted after the InstantSearch library is initializedalgolia.instantsearch.hitClickAction
is emitted when a user clicks on an InstantSearch result- Deprecated from March 31, 2025.
- Use
beforeInstantSearchProductTemplate
for adding click events
algolia.instantSearch.onError
is emitted when the InstantSearch library. reports an erroralgolia.instantSearch.onRender
is emitted when all InstantSearch widgets have been renderedalgolia.instantsearch.beforeInitSortOrders
is emitted before InstantSearch sorting is initializedalgolia.instantsearch.beforeInitFacets
is emitted before InstantSearch facets are initializedalgolia.hooks.initialize
is emitted before Algolia hooks have been initializedalgolia.analytics.beforeInit
is emitted before the Algolia Insights API has been initialized
Example
1
2
3
document.addEventListener('algolia.autocomplete.afterInit', function() {
console.log("Autocomplete.js has been initialized")
});