Insights hooks
The following hooks change aspects of the Insights integration for sending click and conversion events.beforeAlgoliaAnalyticsOptions
Changes options for the Insights library.
Parameters
Returns
object
Modified Insights options.
Examples
Opt out of Insights events
Opt out of Insights events
Set
userHasOptedOut to true to prevent the integration from sending Insights events.JavaScript
beforeAddToCartSelector
Changes the CSS selector for the add-to-cart button.
Parameters
string
Default CSS selector for the add-to-cart button:
'[name="add"]'.Returns
string
Modified CSS selector.
Examples
Use a custom add-to-cart selector
Use a custom add-to-cart selector
Return a custom selector if your theme uses a different add-to-cart button.
JavaScript
Recommend hook
This hook changes the behavior of recommendations from Algolia Recommend.beforeRecommendHitTemplate
Customize the HTML template that renders the recommendations panel.
Parameters
Default template.
Tagged template function for rendering HTML.
object
Recommendation item.
Returns
Template to render.
Examples
Customize the recommendation item template
Customize the recommendation item template
Return a custom HTML template to match your theme’s recommendation card layout.
JavaScript
beforeAddToCartSelectorString (deprecated)
This hook is deprecated.
Use
beforeAddToCartSelector instead.Parameters
string
default:"'[name=\"add\"]'"
CSS selector.
Returns
string
CSS selector.