Analytics

Site search tracking in GA4

How GA4 tracks searches on your store with view_search_results, how to set the search parameter, where to find the terms and what they tell a webshop.

·6 min read·By the ROASaurus team

Key takeaways
  • GA4 tracks site search through enhanced measurement: a view_search_results event fires when a page loads with a search parameter in its URL.
  • By default GA4 looks for q, s, search, query or keyword; Shopify's search results page uses q, so it works without changes.
  • The search term lands in the built-in Search term dimension; you do not need a custom dimension for it.
  • Search boxes that show results without loading a new page, such as many predictive search dropdowns, are not tracked by enhanced measurement.
  • Search terms are typed by shoppers, so they can contain email addresses or order numbers; keep them out of GA4.

Site search tracking in GA4 records what visitors type into your store's search box. With enhanced measurement on, GA4 sends a view_search_results event each time a page loads with a search parameter in its URL, and stores the query in the Search term dimension. You find the terms in Reports › Engagement › Events under view_search_results, or in an exploration with Search term as the row.

This guide shows how to set it up, how to check that your store's search parameter is covered, where the reports are and what a webshop can learn from the terms.

How to set up site search tracking in GA4

First find your store's search parameter. Search for something on your own site and look at the address of the results page. On a Shopify store it looks like yourstore.com/search?q=linen+shirt: the parameter is q. A WordPress site often uses ?s=.

  1. Open the web stream

    In GA4, go to Admin. Under Data collection and modification, click Data streams and then your web stream. You need the Editor role or higher.

  2. Check enhanced measurement

    Make sure the Enhanced measurement switch is on, then click the settings icon next to it.

  3. Check Site search

    Site search should be switched on. GA4 looks for the parameters q, s, search, query and keyword by default.

  4. Add your parameter if needed

    If your store uses another parameter, such as st or term, open the advanced settings of Site search and add it to the search term parameters. You can also list additional parameters, such as a category filter, which GA4 then collects as q_ plus the parameter name.

  5. Save and test

    Save, search on your site and open Reports › Realtime or DebugView. A view_search_results event with your term as search_term should appear.

The search_term parameter fills GA4's built-in Search term dimension, so there is no custom dimension to create for it. Only the additional parameters, which arrive as q_ parameters, need registering under Admin › Data display › Custom definitions before they show in reports.

Site search reports in GA4

The Events report

Go to Reports › Engagement › Events and click view_search_results. The event's detail page shows how often it fired and by how many users, with a card for the search terms. Data can take 24 to 48 hours to show in full.

An exploration of search terms

  1. Start a blank exploration

    Click Explore, then Blank. Name it Site search and set a date range such as the last 30 days.

  2. Import dimensions and metrics

    Click + next to Dimensions and import Search term and Event name. Click + next to Metrics and import Event count, Total users and Event count per user.

  3. Build the table

    Double-click Search term to make it the row, and the metrics to make them values.

  4. Filter on the event

    Drag Event name to Filters, choose exactly matches, pick view_search_results and click Apply.

  5. Add a purchase view

    Add a session segment that includes view_search_results, then compare it with a segment of all sessions on purchases and revenue. That shows whether searchers buy more or less than other visitors.

Search termSearchesUsersWhat it tells the store
linen shirt640510Core demand: check that the top results are in stock in all sizes
gift card210195Make gift cards easier to find from the menu
size guide180170Shoppers cannot find it on product pages
returns150142A support question: link the returns page in the footer and the checkout
linnen9084A spelling variant: add it as a synonym in the search app
swim shorts7570A product you do not sell yet
Example store, one month of view_search_results by search term.

What is site search tracking?

Site search tracking is collecting and analysing the queries visitors type into the search box on your own site. Unlike search engine keywords, these are people who are already on your store and tell you, in their own words, what they want. A search is one of the clearest signals of intent a webshop gets.

What search terms reveal
  • Products shoppers expect you to sell
  • The words they use for your products
  • Spelling variants and synonyms
  • Pages they cannot find in the menu
  • Seasonal demand before it shows in sales
What to do with it
  • Add products or collections
  • Rename products and categories
  • Add synonyms to the search app
  • Fix navigation and footer links
  • Plan stock and campaigns earlier
Search terms turn into concrete tasks for merchandising, content and navigation.

The advantages of site search tracking

  • Demand you are missing. Frequent searches for products you do not carry are a list of possible additions to the range.
  • Better search results. Terms that lead to no product view or a quick exit point at results that do not match. Fix them with synonyms, redirects or better product titles.
  • Better navigation. Searches for size guides, returns or delivery times show information that should be one click away.
  • Language for ads and SEO. Shoppers' own words make good keywords for search ads and titles for collection pages. See organic search traffic in GA4 for the other side of search.
  • A conversion signal. Comparing sessions with and without a search shows whether your search helps shoppers buy; see conversion rate in GA4.

Site search is one of the enhanced measurement options; the others are covered in GA4 enhanced measurement events. If searchers seem to arrive from nowhere, read about direct traffic in GA4. The full Shopify setup is in GA4 for Shopify and the ecommerce events in GA4 ecommerce events for Shopify. Before a sale period, the BFCM tracking checklist is a good moment to review your top search terms.

Site search and ROASaurus

ROASaurus does not record search terms itself: its first-party script measures visits, product views, carts, checkouts and orders, not what shoppers type in the search box. Site search stays a GA4 job. What ROASaurus adds is a place to read it next to your sales. After a read-only Google login, the GA4 explorer under Website › Search runs any GA4 query: set the dimension to searchTerm, the metric to eventCount, filter eventName on view_search_results, and export the result as CSV.

searchTermeventCounttotalUsers
linen shirt640510
gift card210195
size guide180170
Example data for a fictional store, as the GA4 explorer returns it: API field names as column heads.

To make sure the purchases those searches lead to reach GA4, even when the browser blocks GA4's tag, add GA4 as a server-side destination under Connections › Tracking & destinations. See server-side tracking and what server-side tracking is.

Sources

  1. Google Analytics Help: Enhanced measurement events
  2. Google Analytics Help: Best practices to avoid sending PII
  3. Google Analytics Help: Data redaction

In ROASaurus

Keep reading

MarketingBFCM tracking checklist: can you trust your ad results?A Black Friday tracking checklist: test a real purchase, find duplicate conversions, choose which orders count, check consent and judge ads on profit.AnalyticsConversion rate in GA4 for ecommerce, per collectionHow GA4 calculates session and user key event rates, how to get a purchase conversion rate per channel and per collection, and what to fix when it drops.AnalyticsGA4 enhanced measurement events: what they trackWhat GA4 enhanced measurement tracks without code: each event and its trigger, how to switch it on, where to find the data and what it never covers.

FAQ

Questions, answered

More answers in the FAQ and the help center.

How does GA4 track site search?

Through enhanced measurement. When a page loads with a search parameter in its URL, such as ?q=, the GA4 tag sends a view_search_results event with the term as search_term.

Which search parameters does GA4 recognise?

q, s, search, query and keyword by default. Add your own under the Site search option of enhanced measurement in the web stream settings.

Does site search tracking work on Shopify?

Yes for the search results page, which uses ?q=. A predictive search dropdown that shows results without loading that page is not tracked by enhanced measurement.

Do I need a custom dimension for search terms?

No. The search_term parameter fills the built-in Search term dimension. Only additional parameters you collect need a custom dimension.

Where do I see site search terms in GA4?

In Reports › Engagement › Events, click view_search_results. For a full list, build an exploration with Search term as the row, Event count as the value and a filter on the event name.

Every sale, traced to the ad that earned it

Server-side tracking, profit and lifetime value in one app. Free plan, no credit card.