insights
createInsightsMiddleware({ insightsClient: null | InsightsClient, insightsInitParams?: object, onEvent?: (event: InsightsEvent, aa: null | InsightsClient) => void, });
1
import { createInsightsMiddleware } from 'instantsearch.js/es/middlewares';
About this widget
The createInsightsMiddleware
creates an insights middleware to help you achieve the following:
- Set the
userToken
for insights purposes (Click Analytics, Personalization, etc.) - Automatically send events from built-in widgets (you can disable it)
- Lets you send events from your own custom widgets
Requirements
- Use
search-insights
v1.6.2 or later. - Use InstantSearch.js v4.8.3 or later.
Examples
1
2
3
4
5
6
7
const insightsMiddleware = createInsightsMiddleware({
insightsClient,
insightsInitParams,
onEvent,
});
search.use(insightsMiddleware);
Options
insightsClient
|
type: null|InsightsClient
Required
The middleware leverages |
||
Copy
|
|||
insightsInitParams
|
type: object
Optional
(Supported since InstantSearch.js@4.11.0) When given, With With To learn more about the parameters of |
||
Copy
|
|||
onEvent
|
type: (event: InsightsEvent, aa: null | InsightsClient) => void
default: undefined
Optional
By default, the middleware sends events to Algolia using the provided If you want to use The
|
||
Copy
|
Custom events
Connectors
|
Many of the InstantSearch connectors expose the Here’s a list of connectors that expose
|
||
Copy
|
|||
Hits
|
The The
Copy
When clicking the button, InstantSearch automatically catches the event and sends it to Algolia, or forwards it to
|
||
Copy
|