Skip to main content

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

object
Insights options.

Returns

object
Modified Insights options.

Examples

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

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

Return a custom HTML template to match your theme’s recommendation card layout.
JavaScript

beforeAddToCartSelectorString (deprecated)

This hook is deprecated. Use beforeAddToCartSelector instead.
Changes the CSS selector for the add-to-cart button.

Parameters

string
default:"'[name=\"add\"]'"
CSS selector.

Returns

string
CSS selector.

See also

Last modified on May 19, 2026