How to Track On-Site Search Terms in Google Analytics 4

https://static.thoughtshift.co.uk/uploads/2023/07/anne-charlotte.webp?21052 - picture
Posted by Anne-Charlotte

Google Analytics 4 reports on on-site searches by default; however, it does not automatically report the specific search terms used by visitors. If you want to gain insights into what your website visitors are searching for, you'll need to configure your property to collect this data. You can then gain valuable data insights to inform your digital marketing strategies.

How to Track On-Site Search Terms in Google Analytics 4 - Supporting graphic
Photo credit: Joshua Sortino

In this comprehensive guide, we'll walk through the steps to enable on-site search term tracking and explain why this data is crucial for optimising your website's user experience and search performance.

Why Report On On-Site Search Terms?

If your website has an on-site search functionality, understanding what users are searching for can provide invaluable insights:

  • Content Discoverability: If users are searching for content or products available on your site but struggling to find them, it may indicate issues with your navigation or internal linking structure. On-site search data can help identify areas for improvement.
  • Content Strategy and Product Development: If users are searching for content or products not currently offered on your site, this data can inform your content strategy and future product development initiatives, allowing you to meet unfulfilled demand.
  • Search Engine Optimisation and Paid Search Strategy: On-site search terms reveal what content and products your visitors are actively seeking, enabling you to optimise your SEO and paid search keyword strategies. Create new category pages optimised for high-demand search terms, update existing content for seasonality, and align your PPC campaigns with precise user language and search behaviour. Dynamically adjust budgets and bids to maximise visibility during peak search periods for specific products or topics.
  • User Experience Optimisation: By understanding what users are searching for, you can enhance the UX of your site by adding content or product tags to your pages and get them to surface for relevant searches, refining your site navigation, or creating new pages to make relevant information more accessible.

In essence, on-site search term data provides a direct line into your audience's needs and interests, offering a real opportunity to improve your website's performance and user experience.

Setting Up On-Site Search Term Tracking in GA4

Follow these steps to enable on-site search term tracking in your GA4 property:

  • First, you must ensure that site search is enabled in your GA4 property. To check this, head to your GA4 property and go to the Admin section.
  • Under Data Collection and Modification, click on Data Streams and select your website data stream.
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
View fullsize image
  • In the Events section, ensure that Enhanced Measurement is enabled, and click on the gear icon.
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
View fullsize image

You will be able to ensure Site Search is enabled and view advanced settings. By default, GA4 features common search term query parameters: q, s, search, query, keyword.

How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
View fullsize image

What are search term query parameters?

They designate internal query parameters; they are parameters attached to the end of a URL when a user performs an on-site search. To find the search term query parameter on your website, perform an on-site search and look at the added parameter in the URL, just before your search terms.

For example, on the Google Merchandise Store's website, when searching for "tshirt" in the site search functionality, the URL becomes:

https://shop.merch.google/search?keyword=tshirt. Here, we can see that the search query parameter is "keyword".

  • The next step is to perform a search on your own website to identify your search term query parameter (it will always be before "=", followed by your search terms, in the URL).

Ensure your search term query parameter is listed in the parameter field in GA4. If it isn't, add it to the list or replace all entries with your parameter. Do not include the "=" sign in the field. For instance, if your URL looks like this when you search for "tshirt" on your site:

www.yourdomain.com/search?st=tshirt, your Search Term Query Parameter in GA4 must be "st".

How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
View fullsize image
  • Save your configuration by clicking the Save button in the upper right corner of the Enhanced Measurement settings.
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console

As of March 2024, this configuration alone does not enable GA4 users to view their on-site search terms in their view search results event report. To enable site search terms to be reported, you must create a custom dimension.

  • In the Admin area, click on Data Display, then Custom Definitions.
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
  • Click on "Create a Custom Dimension," and create a "search_term" custom dimension:
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
  • Save by clicking on the top right-cornered button. This custom dimension will enable a new data card to be shown in your view_search_results events report.

Analysing On-Site Search Terms in Google Analytics 4

Once the setup is complete, you can access and analyse your on-site search term data within the GA4 interface:

  • Navigate to the "Events" report and locate the "view_search_results" event.
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console
View fullsize image
  • Click on the "view_search_results" event to open the event dashboard.
  • The "search_term" data card displays the specific search terms used by your visitors, along with event count (corresponding to how often each term has been searched for, for the period you have selected) and user metrics.
How to Track On-Site Search Terms in Google Analytics 4 - Supporting screenshot of analytics console

From here, you can further analyse the data by applying filters and comparisons to identify trends, patterns, and opportunities for optimisation. By leveraging the power of on-site search term data in GA4, you can gain a deeper understanding of your audience's needs and behaviours, enabling data-driven decisions that drive better website performance.

If you need help configuring your GA4 property, or need assistance with your GA4 data, or any other web analytics needs, contact our team of Digital Analytics experts.