Overview
Algolia Insights tracks user behavior to:- Improve relevance with Click Analytics
- Personalize results based on user behavior
- Run A/B tests to optimize search
- Analyze performance with detailed metrics
Basic Setup
- Loads the Insights library if not already present
- Initializes with your app credentials
- Manages anonymous user tokens
- Enables
clickAnalyticson searches
Installation
Install the Insights library:Setting User Token
Authenticated Users
Set the user token for logged-in users:Anonymous Users
The middleware automatically generates and persists anonymous tokens:Sending Events
InstantSearch widgets with insights support automatically send events:Click Events
Conversion Events
View Events
Custom Event Handling
Intercept and modify events before sending:User Token Management
The middleware handles user token lifecycle automatically:Click Analytics
Enable to track which results users click:Custom Insights Client
Use a custom Insights implementation:Server-Side Rendering
For SSR, set the user token in initial state:Event Types
Click Events
Track when users click results:Conversion Events
Track when users convert:View Events
Track when results are viewed:Deduplication
View events are automatically deduplicated per query:Debugging
Enable logging to debug events:Best Practices
Set User Tokens Early
Set authenticated user tokens before InstantSearch starts.
Use Descriptive Names
Use clear, consistent event names for better analytics.
Track Conversions
Track all conversion points: add-to-cart, purchase, signup.
Test Events
Use the Events Debugger in Algolia dashboard to verify events.