This project is not covered by Drupal’s security advisory policy.

Site search analytics for Drupal. Search Insights shows how well your site search works, and what to do about it: your search success rate, the keywords visitors cannot find, what they search for instead, and the topics suddenly in demand.

Features

  • Search success rate: the share of searches where the visitor found a result worth clicking and stayed with it. On the report, and in a block for your dashboard.
  • Content gaps: the keywords that find nothing, or nothing worth clicking, those that fail most first.
  • What visitors meant: what people searched next when a search fell short. "fafsa" found nothing, then "financial aid" did: a synonym to add. When the next search fails too, it is content to write.
  • Trending and new topics: keywords whose share of searches jumped, or that were not searched before, compared with the weeks before.
  • Results that rank too low: how far down the results people clicked were.

All of it per keyword and language, for the last 7, 30, or 90 days. Search Insights sets no cookies and stores no visitor identifiers: only daily totals.

A search succeeds when the visitor finds a result worth clicking and stays with it. It falls short when it finds nothing, when the visitor tries different words without clicking, or when they click a result, come straight back, and search again.

It works with Search API on any backend (Solr, Database, Acquia Search), for Search API Page results and Search API views.

Methodology

Counting searches that find nothing catches only part of the picture: a search that returns ten pages, none of them useful, looks fine by that measure. Search research judges success by what people do next. A Microsoft Research study found that the next query, how soon it comes and how similar it is, indicates whether a searcher was satisfied more accurately than clicks do, and that the best model uses both.

Search Insights applies that idea on your own site: a search counts as a success when a result was clicked and the visitor did not come straight back to search again. Commercial search platforms measure similar signals.

Metrics

Every day, for each keyword and language on each index:

  • Searches: how many times it was searched.
  • Average results: how many results a search found.
  • Clicked: searches where a result was clicked.
  • Average position: how far down the clicked results were (1 for the top one). A keyword clicked far down has content that exists but ranks low.

And where searches fell short:

  • No results: searches that found nothing.
  • Refined: a different search soon after, with no click on the results.
  • Bounced back: a click, back on the results soon after, then a different search.

A search succeeded unless it found nothing, was refined, or bounced back; the share that succeeded is the search success rate. A click that is not followed by a quick return counts as a click that helped.

The report also identifies keywords people are suddenly looking for: Trending when their share of all searches is at least half as big again as in the period before, and New when they were not searched in the prior period. The last 7 days are compared with the 4 weeks before, and the last 30 days with the 60 days before; there are no trends for 90 days, or when daily totals are not kept long enough. A term must be searched at least 10 times in the period to be eligible.

Next searches

When a search falls short, what people search next often says what they meant: "fafsa" found nothing, then "financial aid" did. For each pair of searches, Search Insights counts how often the second followed the first soon after. The report shows pairs seen at least twice in the period, most frequent first, with how often searches for the next keywords succeeded: high when the new words found what people wanted (a synonym to add), low when they did not either (content to write). Each keyword on the report links to its next searches.

Privacy

Search Insights stores no user, session, IP address, or client identifier: only daily totals per keyword, and per pair of keywords. How one search led to the next is worked out in the visitor's browser, in sessionStorage, which never leaves the browser tab and is gone when the tab closes. Daily totals older than the retention period (90 days by default) are deleted on cron.

Keywords are stored lowercased with single spaces, so "Financial Aid" and "financial aid" are one keyword. Email addresses, card numbers, and long runs of digits (such as phone numbers) are replaced before anything is stored.

How it works

  1. When Search API returns results for keywords a visitor typed, Search Insights signs the search (index, language, keywords, result count, and results page) with a key only the site knows, and adds it to the results page.
  2. A small script on the results page keeps the last search in sessionStorage, and sends events with beacons: each search shown, the first click on its results, and, when the next search comes, how the last one turned out, with the next search when it fell short.
  3. The site accepts only events for searches it signed (both searches, for a pair), from its own pages, and a limited number per visitor an hour, and adds them to the day's totals.

Because the browser reports searches, search pages served from a page cache are counted, and most bots, which do not run scripts, are not.

Searches that are not a visitor's are left out: aborted searches (for example when the visitor may see none of the results), searches whose backend failed (an outage is not a search that found nothing), searches without keywords or with keywords that are not in the address (such as a "related items" view), and searches with excluded query tags, such as autocomplete suggestions.

Similar projects

  • Search API Relevance tunes search relevance: pins, boosts, synonyms, and testing rule changes against past searches. It logs each search, with zero-result and click-through reports (clicks on Search API views), and links no search to the next, so it does not see refined or bounced searches. Use it to change how results rank; Search Insights to find which searches fail.
  • Search API Stats logs each search with its result count and shows the most searched phrases in a block.

Requirements

Configuration

  • Settings: Configuration > Search and metadata > Search Insights (/admin/config/search/search-insights), with the "Administer Search Insights" permission.
    • Indexes to log: none checked logs every index.
    • Refined within: how soon a different search counts as refining the last one (300 seconds by default).
    • Bounced back within: how soon after a click coming back counts as bouncing (30 seconds by default).
    • Keep daily totals for: the retention period (90 days by default).
    • Shortest keywords logged (2 characters by default), and query tags not logged (autocomplete by default).
  • Report: Reports > Search Insights (/admin/reports/search-insights), with the "View Search Insights" permission: the last 7, 30, or 90 days, by index and language, or only Trending or New keywords: the search success rate, where the other searches fell short, and every keyword, those that most need attention first. Its Next searches tab (/admin/reports/search-insights/next) shows what people searched next when a search fell short, for one keyword or all.

Block

Search Insights, for an admin dashboard: the search success rate and the bar of how searches turned out, as at the top of the report, for the last 7, 30, or 90 days, with a link to the report for the details. Shown only to people with the "View Search Insights" permission.

For developers

The Drupal\search_api_insights\SearchInsightsReport service reads the totals:

  • failing(int $days, ?string $index_id = NULL, int $min_searches = 3, float $min_rate = 0.5, int $limit = 50, ?string $langcode = NULL): keywords searched at least $min_searches times that failed at least $min_rate of the time, most failures first, each with its language.
  • popular(int $days, ?string $index_id = NULL, int $limit = 20, ?string $langcode = NULL): the most searched keywords.
  • summary() and keywords(): the totals of a window, and every keyword with its figures.
  • trending(int $days, ?string $index_id = NULL, ?string $langcode = NULL, array $trends = ['trending', 'new']): only the keywords with those trends.
  • pairs(int $days, ?string $index_id = NULL, ?string $langcode = NULL, ?string $keys = NULL): query pairs seen at least twice: the keywords, the keywords searched next, the language, the times, how often the first search found nothing, was refined, or bounced back, how often searches for the first keywords failed in the period, how many of those failures another search followed, and the success rate of all searches for the next keywords in the period.

Each row has the keywords, language, searches, average results, clicks, click rate, average position, no results, refined, bounced back, failures, and failure rate. Rows from keywords() also have the keyword's share of searches, its share in the period before, and its trend (trending, new, or NULL).

Limitations

  • Visitors without JavaScript, and beacons blocked by some browser extensions, are not counted.
  • A click followed by leaving the site looks like a click that helped, even when the visitor left disappointed.
  • Keywords are compared as typed (lowercased): "scholarship" and "scholarships", or a keyword with and without punctuation, are separate keywords.

Credits

The rules for which searches are a visitor's, and the redaction patterns, follow Search API Relevance.

The Trending and New icons are Material Symbols by Google, under the Apache License 2.0.

Search Insights continues Search Log, rewritten for Drupal 11 and Search API.

Maintainers

Supporting organizations: 

Project information

Releases