Guides / Getting insights and analytics / Search analytics / Analytic metrics and reports

Connect Your Search with Google Analytics

Google Analytics Site Search allows you to gain insights into what and how users search on your site. In this guide, we will learn how to set up the site search reports using the Google Analytics UI, so you can combine your search analytics with your website analytics and start measuring the ROI of Algolia.

Before getting started, please add Google’s analytics.js to your site to enable Google Analytics tracking.

Setup

  1. Log in to your Google Analytics account
  2. Navigate to Admin > View > View Settings
  3. Set “Site Search Tracking” to “ON”
  4. Enter your search’s query parameter (e.g. “q”) in the “Query Parameter” field
  5. Check the “strip query parameter out of URL” checkbox
  6. Optional: If your visitors are able to refine searches by categories, enable “Site Search Categories” and enter your category parameter

Capturing search-as-you-type

Google Analytics leverages query strings in the URL to get the terms of your users’ searches (e.g. /search/?q=phone). However, this poses a problem with search-as-you-type experiences. First, the URL of the page does not update with every keystroke. Second, for Google Analytics to register a page view, you need to load the page, which does not happen with search-as-you-type: you remain on the same page while searching.

Luckily, you can use virtual pageviews to solve this problem.

To send a virtual pageview to Google Analytics, we need to write some custom JavaScript code:

1
ga('send', 'pageview', '/?q=' + query + '&f=' + facet);

We need to trigger this code when our user performs an action. This action could be typing in your search box. Using this as a trigger will send a virtual pageview to Google Analytics on every keystroke. Please note that this can clutter your analytics data because a lot of excess queries will show up.

A cleaner approach would be to capture only the full query. You can do this by configuring the analytics widget of InstantSearch.js to debounce and send the virtual pageviews after a few seconds of keyboard inactivity. By default, the analytics widget’s push function triggers after a 3000 milliseconds delay. You can modify this delay using the delay parameter.

Capturing filters

Adding filters to a search does not trigger virtual pageviews. This happens because, by default, the analytics widget does not send virtual pageviews when the user interacts with the search, like a click on filters. To make sure you track filters too, please set the triggerOnUIInteractions parameter to true.

Reporting & Analysis

With your analytics widget set up, and Google Analytics integrated on your site, you will start to see metrics appear in the “Site Search” section of your Google Analytics dashboard.

Site Search Overview

In the “Site Search Overview” report, you can find the following metrics:

  • Sessions with Search
  • Percentage of sessions that used internal search
  • Total Unique searches
  • Results Pageviews / Search
  • Search Exits
  • Percentage of Search Exits
  • Search Refinements
  • Percentage Search Refinements
  • Time after Search
  • Search Depth

You can learn how Google calculates these metrics in their detailed guide. Please note that you might notice differences between the metrics in Algolia Analytics and Google Analytics.

Site Search Usage

In the “Site Search Usage” report, you can find the following metrics:

  • Sessions with and without site search
  • New users engaging with site search
  • Bounce rate
  • Pages viewed per session
  • Average Session Duration
  • Conversions tied to site search (Note: only possible if you configure enhanced ecommerce)

Site Search Search Terms

In the “Site Search Search Terms” report, you’ll find the following metrics broken up by search terms and site search categories.

  • Destination pages
  • Refined keywords
  • Total Unique searches
  • Results Pageviews / Search
  • Search Exits
  • Percentage of Search Exits
  • Search Refinements
  • Percentage Search Refinements
  • Time after Search
  • Search Depth

Site Search Search Page

In the “Site Search Search Page” report, you’ll find the following metrics broken up by start- and destination page.

  • Top search terms
  • Total Unique searches
  • Results Pageviews / Search
  • Search Exits
  • Percentage of Search Exits
  • Search Refinements
  • Percentage Search Refinements
  • Time after Search
  • Search Depth

Did you find this page helpful?