Back in March, we covered how you can set up site search tracking in Google Analytics 4. Here, we are going to look at how you can expose and view the search terms in regular reporting widgets, not just via real-time reporting. When you set up site search tracking and then perform a search, you’ll see the event come through as a view_search_results event in the ENGAGEMENT > EVENTS report:
…but clicking on this to view further details, will only show you a widget containing the list of terms searched in the last 30 minutes. What if you want to see historical data? As we’ve mentioned before, GA4 takes a bit more customisation work than Universal Analytics to get the data that you want, displayed in the right place.
To do this and expose the site search parameter you’ll need to create the event as a custom dimension first.
Exposing Site Search Terms in GA4
- Select CONFIGURE from the menu on the left-hand side of any Google Analytics page…then, select CUSTOM DEFINITIONS on the secondary navigation pane:
2. Select CREATE CUSTOM DIMENSION:
3. In the NEW CUSTOM DIMENSION boxes you’ll find fields for:
- Dimension Name: The name that will appear in your search term widget (report table)
- Scope: Specifies to which data the custom dimension or metric will be applied.
- Description (optional): Free text to describe your dimension further
- Event parameter: The event parameter you want to be exposed in reports
While the dimension name and description are free text boxes, scope is predefined. The event parameter might be available to be selected from a pre-defined list- if not, just type ‘search_term’. When tracking site search, the scope should be set to ‘Event’ and the event parameter should be ‘search_term’ as your objective is to pull through the value of the search term parameter.
search_term is the parameter pulled through on the view_search_results event which is triggered when a user searches your content.
4. Once that’s done, go back to REPORTS > ENGAGEMENT > EVENTS. Then, in the table select view_search_results:
5. On the next page, you might see the event name you selected (in the drop-down box) and a widget that corresponds to the custom dimension name you used to create the search_term dimension:
It is there that you will now see a list of the search terms that people have used to search your site!
6. *Update* Create an Exploration if step 5 does not work: We are aware that step 5 might not always work (sometimes it does, sometimes not – that’s the surprise element of GA4!). If you don’t see the widget showing search queries, you can view the same via an exploration report. To do this navigate to EXPLORE and create a new exploration:
Then, follow the same configuration below:
VARIABLE CONFIGURATION: Name: Site Search Query (or whichever name you choose for your site search report)
Dimensions to import: Search Term and Event Name
Metrics to import: Event Count
TAB SETTINGS CONFIGURATION: Rows: Search Term Values: Event Count Filters: By Event Name Filter contain: view_search_results You should then see your search terms from there: