- 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=.
- 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.
- Check enhanced measurement
Make sure the Enhanced measurement switch is on, then click the settings icon next to it.
- Check Site search
Site search should be switched on. GA4 looks for the parameters q, s, search, query and keyword by default.
- 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.
- 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
- Start a blank exploration
Click Explore, then Blank. Name it Site search and set a date range such as the last 30 days.
- 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.
- Build the table
Double-click Search term to make it the row, and the metrics to make them values.
- Filter on the event
Drag Event name to Filters, choose exactly matches, pick view_search_results and click Apply.
- 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 term | Searches | Users | What it tells the store |
|---|---|---|---|
| linen shirt | 640 | 510 | Core demand: check that the top results are in stock in all sizes |
| gift card | 210 | 195 | Make gift cards easier to find from the menu |
| size guide | 180 | 170 | Shoppers cannot find it on product pages |
| returns | 150 | 142 | A support question: link the returns page in the footer and the checkout |
| linnen | 90 | 84 | A spelling variant: add it as a synonym in the search app |
| swim shorts | 75 | 70 | A product you do not sell yet |
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.
- 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
- Add products or collections
- Rename products and categories
- Add synonyms to the search app
- Fix navigation and footer links
- Plan stock and campaigns earlier
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.
| searchTerm | eventCount | totalUsers |
|---|---|---|
| linen shirt | 640 | 510 |
| gift card | 210 | 195 |
| size guide | 180 | 170 |
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
- Google Analytics Help: Enhanced measurement events
- Google Analytics Help: Best practices to avoid sending PII
- Google Analytics Help: Data redaction