Skip to content
Faisal Mahmud TusherDigital marketing, SEO & analytics
with Faisal Tusher

Marketing Analytics › Google Analytics 4

Site Search Analysis in GA4

Use site search data in Google Analytics: confirm the search event and query, explore search terms, find zero-result and exit searches, and fix them.
Tutorialintermediate10 min readUpdated

What site search data can tell you

Search data answers questions no other report can, because the visitor supplies the words.

  • Demand the site does not meet. Searches that return nothing are visitors who said what they wanted and were told the site did not have it. Some are products the business does not stock; others are products it stocks under another name.
  • Vocabulary the site does not use. Misspellings, plurals, synonyms and series or model names show how customers describe things, which is often not how the catalogue or the navigation does.
  • Navigation that fails. Searches for things the menu already offers, such as delivery, returns or a main category, suggest people could not find them by browsing.
  • Search quality. Searches that end the visit or are immediately refined show results that did not help, even when there were results.

The conversion research methods guide treats analytics as the part of research that is precise about what happened and silent about why. Search terms are the exception, because they carry intent in the visitor's own words, which is why they repay a regular review.

Before you start

  • Explorations, understood. The Explorations tutorial covers the free-form, path and segment techniques this tutorial uses, and the sampling indicator to check before reading a result.
  • The event schema. The events and parameters guide explains event parameters, custom definitions and why an unregistered parameter does not appear in reports.
  • Access. Editor rights on the property to change the stream's search settings and register custom definitions, and publish rights on the Tag Manager container if the search event will be sent from the Data Layer.
  • A developer contact who knows how the site's search works: whether the query appears in the results page address, and whether the results template knows how many results it returned.
  • The BigQuery export, if it is linked, for the exits and refinements step. The BigQuery export basics guide covers the link; the export starts from the day it was linked, so link it now if a later step will need it.
  1. Confirm how the site records a search

    Run a search on the site and look at the results page address. If the query appears as a parameter, the enhanced measurement site search option can record it: the events guide lists view_search_results among the enhanced measurement events, and the GA4 setup tutorial explains that the option depends on the site's query parameter name being in the configured list, so check the stream's settings and add the name if it is missing. If the address does not change, because the search runs inside the page or in an overlay, enhanced measurement cannot see it. In that case the site should push a search event to the data layer when results are shown, carrying the term, and a Tag Manager tag sends it as a GA4 event; the events guide lists search among the recommended events. Write down which route the site uses, the event name and the parameter that carries the term.

  2. Check the query arrives in DebugView

    With Tag Manager preview running, open DebugView and run several searches: a normal term, a term with capitals and extra spaces, a misspelling, a term with no results and a term containing a symbol. For each, click the search event in the timeline and confirm the term arrives as an Event Parameter, spelled as typed, and that one search produces one search event. Two events for one search usually mean the enhanced measurement option and a data layer tag are both active; switch one off. Note the exact name of the parameter carrying the term, because the remaining steps refer to it.

  3. Make the query reportable

    Open a free-form exploration and look for the term in the dimension list. If no available dimension shows it, register the term parameter as an event-scoped Custom Dimension under custom definitions; the events guide notes that registration is not retroactive, so the report fills from the day it is created. Search terms take many distinct values, and the events guide warns that standard reports collapse the long tail of such dimensions into an "(other)" row, which is one reason this analysis lives in Explorations and the export. Normalise where you can. For searches sent through the data layer, lower-case and trim the term and collapse repeated spaces in the push, so that variants group together. For the enhanced measurement route the term arrives as typed, so normalise in analysis, as the export query below does.

  4. Add a results count for zero-result searches

    The search event says what was asked, not what was found. Ask the developer to expose the number of results the template returned, and send it as a second parameter with the search. Enhanced measurement sends its own parameters, so the usual route is to send the search event from the data layer with both the term and the count, and to switch off the enhanced measurement search option so that searches are not counted twice. Register the count as an event-scoped custom dimension, because its job is to filter: the value that matters is zero. If counts vary widely, also send a parameter that only says whether there were results and register that instead. Check both in DebugView with a search that finds nothing.

  5. Build a search terms exploration

    Create a free-form exploration named for the question, with the date range inside the property's retention. Put the term dimension in rows, and event count and total users in values, filtered to the search event. Sort by event count. Add a second tab with the same layout and a filter for a results count of zero: this is the zero-result report the e-commerce conversion hub calls the first one to read. Add a third with device category as a column, because mobile and desktop searches can fail in different ways. Check the sampling indicator on each tab, note on the exploration whether the figures were sampled, and export the tables for the theming step.

  6. Compare searchers with non-searchers

    Build two session segments: sessions that include the search event, and sessions that do not. Apply both as comparisons to a free-form tab with key events, session key event rate and revenue as values, broken down by device. The CVR of each group, which the conversion rate calculator reproduces from the counts, shows how valuable searchers are. It does not show what search adds, because people who search often arrive knowing what they want. The more useful Segmentation is within searchers: sessions whose searches all found results against sessions with at least one zero-result search. That gap is the cost of failing searches. The segment overlap technique answers a related question, how many searchers reached checkout.

  7. Find searches that end the visit or are refined

    A path exploration starting from the search event, with page titles or event names as nodes, shows what people did next: a product page, another search, a category. Another search straight after the first is a refinement, the visitor trying again in different words. Visits that end on the results page are clearer in the export, where every page view in the session can be ordered. The query below, for sites whose results page address carries the query, lists each term with the number of results page views, how many were the last page of the visit and how many were followed by a different search. Set @query_param to the parameter name from the first step.

    WITH views AS (
      SELECT
        user_pseudo_id,
        (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS session_id,
        event_timestamp,
        (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS page_location
      FROM `project.dataset.events_*`
      WHERE _TABLE_SUFFIX BETWEEN @start_date AND @end_date
        AND event_name = 'page_view'
    ),
    terms AS (
      SELECT *,
        LOWER(TRIM(REPLACE(REPLACE(REGEXP_EXTRACT(page_location, CONCAT('[?&]', @query_param, '=([^&#]*)')), '+', ' '), '%20', ' '))) AS term
      FROM views
    ),
    sequenced AS (
      SELECT *,
        LEAD(page_location) OVER (PARTITION BY user_pseudo_id, session_id ORDER BY event_timestamp) AS next_page,
        LEAD(term) OVER (PARTITION BY user_pseudo_id, session_id ORDER BY event_timestamp) AS next_term
      FROM terms
    )
    SELECT
      term,
      COUNT(*) AS results_views,
      COUNTIF(next_page IS NULL) AS ended_visit,
      COUNTIF(next_term IS NOT NULL AND next_term != term) AS refined
    FROM sequenced
    WHERE term IS NOT NULL AND term != ''
    GROUP BY term
    ORDER BY results_views DESC
    

    For searches sent from the data layer, apply the same ordering to the search event and the page views that follow it.

  8. Group terms into themes

    Individual terms are too many to act on; themes are a work list. Export the terms with their searches, zero-result counts, exits and refinements into a spreadsheet, and assign each frequent term to a theme: product or category names, brands or authors, series or model names, misspellings and plurals, synonyms the catalogue does not use, codes and references, service questions such as delivery and returns, and products the business does not sell. For each theme, total the searches and work out its share of zero-result searches and of exits. The themes with the most failing searches are the first fixes; a theme of products the business does not sell is a buying question, not a search fix, and goes to whoever owns the range.

  9. Fix the top themes and measure again

    Each theme has its own fix. Synonyms map the customer's word to the catalogue's. Spelling tolerance or explicit corrections handle frequent misspellings. Searches for a category, a service page or a series can be sent straight to the right page. Service questions need the answer findable from search and from the menu. Ranking and merchandising changes belong to the e-commerce conversion hub. Record each fix in the measurement change log with the themes it targets, then rerun the same exploration tabs and export query for a comparable period afterwards and compare, theme by theme, the zero-result share, the exit share and the share of searching sessions that converted. Repeat the review monthly.

A month of searches, read (illustrative)

The example applies the steps to a small shop with a search log nobody had read.

Illustrative example — not a real result

Moonfeather Bookshop reads its zero-result searches

Moonfeather Bookshop is an invented independent online bookshop. Its search sends the query in the results page address, so enhanced measurement already recorded searches; the team adds a data layer search event with a results count and switches the enhanced measurement option off. In the first full month there are 9,400 searches, of which 1,320 (14%) return nothing. In the export, 58% of zero-result searches are the last page of the visit, against 21% of searches that found results.

Theme (first month)Zero-result searchesFix
Series names410Synonyms mapping each series name to its books
Misspelt authors380Corrections for the 40 most misspelt author names
Gift cards and delivery150Searches sent straight to the gift card and delivery pages
Formats and ISBNs120ISBN search enabled; format words added as synonyms
Everything else260Reviewed monthly

The next month has 9,250 searches and 610 zero-result searches (6.6%). Zero-result searches for series names fall to 60 and for authors to 90, the exit share of searches in those two themes falls from 61% to 27%, and orders from sessions with a series-name search rise from 18 to 71. Searching sessions still convert at 6.8% against 2.3% for sessions without a search, a gap the shop no longer reads as the effect of search itself.

Search data and personal data

People type all sorts of things into search boxes, including their own email address, a phone number, an order reference or another person's name. The search term parameter carries whatever they typed into analytics and the BigQuery export, where everyone with access can read it. The guide to keeping personal data out of analytics lists site search as one of the routes and gives a sweep that finds such values.

The fix is redaction, not switching search off. For searches sent through the data layer, replace values that match agreed patterns (an at sign followed by a domain, long runs of digits, the format of the business's own order references) with a placeholder in the push or in a container variable before the event is sent. For the enhanced measurement route, the term comes from the page address, so the same patterns have to be handled where the page location is cleaned. Add the search term to the fields the regular sweep checks, and never paste examples of found values into tickets or chats.

Common mistakes

  • Assuming search is tracked. Enhanced measurement needs the right query parameter, and in-page searches need a data layer event; check before analysing an empty report.
  • Counting each search twice. The enhanced measurement option and a data layer tag both active.
  • No results count. Without it, zero-result searches, the most useful report, cannot be found.
  • Reading terms in standard reports. The long tail collapses into "(other)"; use Explorations and the export.
  • Crediting search with searchers' conversion rate. Searchers arrive with intent; compare failing and successful searches instead.
  • Fixing terms one at a time. Themes turn a long list into a few fixes with measurable effects.
  • Not measuring again. A fix without a before-and-after comparison is a guess.
  • Turning search tracking off over personal data. Redact the patterns and keep the most direct record of customer intent the site has.

The GA4 hub lists the other guides on events, reports and Explorations that this tutorial builds on.

Frequently asked questions

Why does GA4 show no site search data even though people search the site?

Usually because the search event never fires. The enhanced measurement search option recognises a search from a query parameter in the results page address, so it misses sites whose parameter name is not in the configured list and sites whose search updates the page without changing the address. Check a real search URL against the parameter list in the data stream settings, and for searches that never reach the address, push a search event to the data layer instead.

Do people who use site search convert better because of the search?

Not necessarily. People who search often arrive knowing what they want, so they would convert better than browsers even with a poor search. Comparing searchers with non-searchers shows how valuable searchers are, not what search adds. To learn what search itself contributes, compare searchers whose searches found results with those whose searches did not, and measure again after fixing the failing searches.

Should we stop tracking site search because people type personal details into it?

No. Redact the patterns instead. The search log is one of the most useful sources a site has, and the personal data in it comes from a small number of recognisable patterns such as email addresses, phone numbers and order references. Replace matching values with a placeholder before the term is sent, sweep the reports and the export for anything that slips through, and keep the search tracking running.

Terms used on this page

Tools to try

Where this page is used

Also related

Sources

  1. [GA4] About events — Google Analytics Help
  2. [GA4] Get started with Explorations — Google Analytics Help
  3. [GA4] Set up BigQuery Export — Google Analytics Help

Related