Skip to main content
DocSearch integrates with Algolia Insights to provide powerful analytics on search behavior, click patterns, and user interactions.

Overview

Algolia Insights enables you to:
  • Track search queries and click-through rates
  • Measure search relevance and effectiveness
  • Understand which results users interact with
  • Optimize your search experience based on user behavior
  • Send custom analytics events
Algolia Insights is built on the autocomplete-plugin-algolia-insights package, which integrates seamlessly with DocSearch.

Setup

To enable analytics, pass the insights configuration to DocSearch:
Setting insights={true} enables basic click analytics. For advanced use cases, you can pass a custom insights configuration.

How It Works

When insights are enabled, DocSearch automatically:
  1. Adds clickAnalytics parameter to search requests
  2. Includes userToken to identify anonymous users
  3. Tracks clickedObjectIDsAfterSearch events when users select results
  4. Sends events to Algolia Insights API

Search Request Changes

With insights enabled, search parameters include:

Click Event Tracking

When a user clicks a search result:

Advanced Configuration

For more control over insights tracking, pass a custom configuration:

Event Types

DocSearch tracks these Algolia Insights events:

Click Events

Event Name: Item Selected Triggered when a user clicks on a search result.

Search Events

Automatically tracked with clickAnalytics: true in search parameters.

User Token Management

Algolia Insights uses user tokens to track individual users across sessions:

Custom User Token

If you have authenticated users, set their user ID:

Custom Analytics Integration

Combine Algolia Insights with your existing analytics platform:

Google Analytics 4

Mixpanel

Segment

Implementation Details

Here’s how DocSearch implements insights tracking internally:

Enable Click Analytics

Track Click Events

Initialize Autocomplete with Insights

Viewing Analytics Data

Access your search analytics in the Algolia dashboard:
1

Navigate to Analytics

Go to your Algolia dashboard and select your index
2

View Search Analytics

Click on “Analytics” in the sidebar to see:
  • Top searches
  • Search with no results
  • Click-through rates
  • Popular results
3

Enable Click Analytics

Make sure “Click Analytics” is enabled in your index settings

Privacy Considerations

When using insights, consider privacy regulations like GDPR and CCPA:
  • User tokens should be anonymized or hashed
  • Provide opt-out mechanisms for tracking
  • Include analytics disclosure in your privacy policy
  • Consider cookie consent requirements

Conditional Tracking

Troubleshooting

Events Not Showing Up

1

Verify insights enabled

Check that insights={true} or insights object is passed to DocSearch
2

Check API key permissions

Ensure your API key has search and analytics permissions
3

Verify queryID

Click events require a queryID from search results
4

Check network requests

Look for requests to insights.algolia.io in browser DevTools

Click Analytics Not Working

Make sure clickAnalytics is enabled in your search parameters:

Best Practices

1

Always enable insights

Enable insights from day one to build a baseline of analytics data.
2

Use consistent user tokens

For authenticated users, use their user ID as the token for accurate tracking across sessions.
3

Combine with custom analytics

Use both Algolia Insights and your existing analytics platform for comprehensive tracking.
4

Monitor search quality

Regularly review analytics to identify searches with low click-through rates or no results.
5

Respect user privacy

Implement proper consent mechanisms and provide opt-out options.
6

Test in development

Test insights events in development using browser DevTools to verify they’re being sent correctly.

TypeScript Interface

The insights prop accepts the same configuration as the Autocomplete Insights plugin, giving you full control over analytics behavior.