How to Track Site Search in GA4

The site search functionality lets visitors quickly find content or products they are interested in. It makes navigation easier, especially if your site has many pages or a complex structure.

Site search tracking in Google Analytics 4 (GA4) shows how a user interacts with the site. This is useful for optimizing and improving the user experience.

In this article, let me tell you how to track site search in GA4, verify that it’s working correctly, and analyze the data you receive.

  1. What is a site search?
  2. Why you should track site search
  3. How to set up a default site search
  4. Tracking searches without query parameters
  5. How to verify that search tracking is working correctly
  6. Analyzing the site search report

What is a site search?

Site search is a feature that allows users to find content on a website by entering queries into a search box. Essentially, it helps them find the information they are looking for without having to browse through each page of the website.

Site search is usually implemented using standard HTML forms or JavaScript libraries, such as jQuery or Angular. Third-party services, such as Google Custom Search, are sometimes used.

Why you should track site search

Tracking allows you to gather valuable information about how users interact with your website. This information can help you improve your marketing strategy and individual pages. Here are some of the ways you can use tracking results:

  1. Understand user intent. Search tracking helps you identify the queries that lead to the most successful pages on your site. Focus on developing this content to increase traffic.
  2. Creating new content. When you know what users are looking for on your site, you can meet their needs and provide the information they want. For example, if many users are looking for information about a specific product, add that information. This makes the site more useful to users.
  3. User experience (UX) optimization. Tracking allows you to better understand how users interact with and search for content. By analyzing search queries, you can improve site structure and navigation.

Setting up a default site search in GA4

Step 1: Make sure the site has a search function.

Check if the site has a search function and test it by entering a search query. If everything works as it should, you will see a tracking option in the address bar. In my example, I am using one of the standard tracking parameters: query. You can also use q, s, term, search, query, or keywords.

make-sure-the-site-has-a-search-function

Step 2: Enable enhanced measurement events.

This GA4 feature allows you to collect the data you need. Go to your Google Analytics account settings and enable “Enhanced measurement” to find it. When you enable this option for a web data stream, Google Analytics will immediately start collecting the events enabled in this section.

Коли ви вмикаєте цей параметр для потоку вебданих, Google Analytics одразу починає збирати події, які увімкнені у цьому розділі.

Коли ви вмикаєте цей параметр для потоку вебданих, Google Analytics одразу починає збирати події, які увімкнені у цьому розділі.

Коли ви вмикаєте цей параметр для потоку вебданих, Google Analytics одразу починає збирати події, які увімкнені у цьому розділі.

In addition to enabling the feature itself, make sure that search tracking is enabled in its settings.

Окрім ввімкнення самої функції, перевірте в її налаштуваннях, що відстеження пошуку також увімкнене.

Step 3: Add the query parameters.

In the above example, the query parameter is query.

Note: You do not need to type additional characters. If the query parameter is defined by the word query, type query only, not query=.

Не потрібно вводити додаткові символи: якщо параметр запиту визначається словом query, вводьте лише query, а не query=.

Step 4: Add additional parameters if necessary.

If additional parameters (title, category) appear in the URL during the search, you should add them. This will store additional search data on the site. For example, if you want to analyze searches by product category, add the “Category” parameter to the list in the bottom field.

Якщо хочете аналізувати пошук за категоріями товарів, додайте параметр «Категорія» до переліку у нижньому полі.

If the URL link contains an additional parameter, such as title, add it as well to track that data.

Якщо посилання у полі URL містить додатковий параметр, наприклад «title», також вкажіть його, щоб відстежувати ці дані.

Step 5: Save the settings.

After you’ve added additional queries, save the settings and go to your website to ensure that search tracking is working. Later, I’ll show you how to check if your Google Analytics tracking is working correctly.

Step 6: Create a special search_term event parameter.

When you enable tracking, you will have information about the number of times users have searched your site. To find out the specific queries they were searching for, you need to create a special parameter. To do this, go to the Custom definitions section.

Для цього зайдіть у розділ «Спеціальні визначення».

Click Create custom dimension.

Натисніть кнопку «Створити спеціальний параметр».

Specify the dimension name and scope, and select the search_term event parameter from the list.

Вкажіть назву параметра, область та оберіть із списку параметр події — «search_term».

Read more in A Guide to Audit Google Analytics 4.

Tracking searches without query parameters

If your site has a JavaScript site search feature, it will not have a specific search query parameter. However, it can still be tracked by GA4.

Втім, його теж можна відстежувати через у Google Analytics 4 (GA4).

To do this, use events and special events to track search activity:

  • Create a special JavaScript variable in GTM. This is needed to extract the search query from the URL.
  • Create a GA4 tag to pass information about the view_search_results event, which contains information about the search_term parameter.
  • In preview mode, check if the customized data is sent to GA4.

Analytics Mania describes this process in more detail, and I recommend their setup guide.

How to verify that search tracking is working correctly

Google Analytics Debugger

Google Analytics Debugger is a browser extension that allows you to debug and verify the accuracy of the Google Analytics tracking code on your website. Follow the steps below:

1. Install the Google Chrome extension (Google Analytics Debugger) if it is not installed on your browser.

Встановіть розширення для Google Chrome — Google Analytics Debugger, якщо його ще немає у браузері.

Встановіть розширення для Google Chrome — Google Analytics Debugger, якщо його ще немає у браузері.

  • Go to the website for which you’re setting up search tracking, and make sure the GA debugger is enabled.

Перейдіть на сайт, для якого робите налаштування відстеження пошуку та переконайтесь, що GA Debugger увімкнено.

  • After that, try searching on the site you want to check.

ga-debagger

2. In the GA4 Admin menu, click DebugView.

У меню адміністратора в Google Analytics 4 знайдіть розділ DebugView і перейдіть в нього.

3. Wait until the view_search_results event appears in the section.

Почекайте поки в розділі з’явиться подія пошуку «view_search_results».

4. In the upper right corner of the section, you will find an events report for the last 30 minutes. Locate the view_search_results event and click on it.

Знайдіть у ньому подію view_search_results та натисніть на неї.

5. Among the options, locate search_term and click on it.

Серед параметрів знайдіть search_term та натисніть на нього.

6. If you can see your request, everything is set up and working correctly.

Якщо відображається ваш запит, все налаштовано і працює правильно.

Realtime report

This report displays the number of visitors using site search at the moment of viewing and the queries they use. To view the report, log in to your GA4 account, go to the Reports tab, and select Realtime.

Для перегляду звіту ввійдіть до облікового запису Google Analytics 4, перейдіть до вкладки «Звіти» та виберіть «Звіт у реальному часі».

Locate the events report and the view_search_results event.

Знайдіть звіт по подіях та подію view_search_results.

Next, go to search_term and see if your query appears.

Далі перейдіть до search_term та подивіться, чи з’явився ваш запит.

search-term-ice-cream

If you can see search data on the site, the tracking is working correctly.

Read more in our blog posts:

  1. How to Link Google Ads to Google Analytics 4: A Step-by-Step Guide
  2. How to Track Events with Google Analytics 4: The Ultimate Guide.
  3. Cookieless Tracking in Google Analytics 4: Strategies and Best Practices.

Analyzing the site search report

You have successfully set up search tracking on your site and verified that it works correctly. Now, you have data on how website visitors are using site search on your site. It will help you understand which topics and products are popular with users and give you ideas for creating new content or improving existing content.

You can use several tools to analyze site search data in GA4.

Standard events report

The events report shows how often the site’s search function was used and what queries were searched for. It also provides information about the pages users open while searching the site.

To view the report, go to Reports > Engagement > Events.

Для перегляду звіту зайдіть до розділу «Звіти» — «Взаємодія» — «Події».

Add the desired view_search_results event to the search.

Введіть у пошуку потрібну подію «view_search_results».

Введіть у пошуку потрібну подію «view_search_results».

Введіть у пошуку потрібну подію «view_search_results».

The report will look like this:

Звіт виглядатиме наступним чином.

How to create an exploration

To get more information, create a search query report in GA4. It will give you additional information about the queries users used to search your site, as well as information about:

  • the number of search results; 
  • the number of clicks on the search results; 
  • the frequency of use of certain queries, and much more.

To create a report, go to Explorations and select a blank report.

Для створення звіту перейдіть у розділ «Дослідження» та оберіть звіт вільної форми.

Name the exploration, select the period, and add dimensions and metrics.

Дайте назву дослідженню, оберіть період, додайте показники та параметри.

In the settings, add the search_term parameter to the string.

У налаштуваннях додайте у рядок параметр search_term.

Add the Events per session and Event count per user metrics.

Додайте показники «Кількість подій за сеанс» (Events per session) та «Кількість подій на користувача» (Event count per user).

Add a filter on events so that only the view_search_result event is displayed.

Додайте фільтр на події, щоб відображалась лише подія «view_search_result».

And that’s it! You will get a ready-made report of search queries on your website for the selected period.

and-thats-it

Conclusions

  1. Site search tracking allows you to learn about the preferences of your site visitors and identify their needs. This information can help you add new products or brands to your site or add content that users are interested in.
  2. To set up site search tracking, follow these steps:
    • make sure that site search is enabled;
    • enable enhanced measurement events;
    • add new queries if necessary;
    • save the settings;
    • create a special search_term parameter.
  3. Check the accuracy of your settings in the Google Analytics Debugger or using Realtime reports.
  4. Analyze the data in a standard event report or your own custom research report. You can then use the results to improve your marketing strategy and advertising campaigns.
Topics:
1
0
Found a mistake? Select it and press Ctrl + Enter