Why track searches with no results?
Every query in your internal search engine is a raw expression of intent. Faced with a no-results page, the user generally leaves the site, leaving no trace of the mismatch with your offer.
You then miss out on 3 major levers: lexical alignment (your customers do not use your terms), the continuous optimization of your content and, above all, the opportunity to identify new features for your offer.
Set up tracking for unsuccessful searches
If GA4 tracks basic searches (through URL parameters like q or search), it ignores dead ends. Rather than creating a new event, add to the existing search event a parameter that says whether there are results or not.
Step 1: Check search tracking in GA4
In GA4, go to Admin > Data streams, open your web stream then click the gear of Enhanced measurement. Check that the Site search line is on. If your site uses a parameter other than q or search, add it in the advanced settings of this line.
Step 2: Identify the "No results" message in GTM
Right-click the message displayed when a search finds nothing, then choose Inspect to note its class (for example: no-results). In Google Tag Manager, go to Variables > New, choose the DOM Element type, with the CSS selector selection method (.no-results) then name it Search - no results message.
Step 3: Turn the message into a results variable
Create a variable of type RegEx Table named Search - results, with the Search - no results message variable as input. Add a row with the expression .*no results.* (reuse the words of your site's message) and the value no results, then set the default value to with results. If the message is displayed, the variable returns no results. Otherwise, it returns with results.
Step 4: Add the parameter to the Google tag
In your Google tag, open the Configuration settings section and add the search_results parameter with the value Search - results. Also replace its trigger with DOM Ready: the message must already be displayed when the variable is read.
Step 5: Register the dimension in GA4
In GA4, go to Admin > Data display > Custom definitions and click Create custom dimension. Name it "Search results", set the scope to Event and select the search_results parameter.
Explore these searches in Google Analytics
In the report or exploration where you already track your searches, add the Search results dimension then a filter with the condition exactly matches no results. Without an existing report, open the Explore menu, create a Free form exploration and add the following items:
- Dimensions: Search term, Search results
- Metrics: Event count
Filter on Event name exactly matching view_search_results, then sort in descending order: you get the terms your site cannot satisfy.
How to use searches with no results
- Adapt your offer: if a product or a service keeps coming back, consider adding it to your catalog.
- Adapt your content: if the visitor looks for information you already have (delivery, pricing), make the page visible in your menu.
- Adapt your wording: if the visitor uses a different word than you or misspells it, reuse their words in your pages and add this synonym to your search engine.
Tools
- Google Tag Manager: DOM Element and RegEx Table variables, Google tag.
- Google Analytics 4: enhanced measurement, custom dimension, free form explorations.
Detecting searches with no results is part of the tracking expertise.