Site Search Tracking and Reporting

Site Search allows you to track how people use your website’s internal search engine. You can see:

  • What search keywords visitors used on your website’s internal search.
  • Which of those keywords resulted in no results (and thus what content your visitors are looking for but cannot find).
  • What pages visitors visited immediately after a search.
  • What search categories visitors use (if your website employs search categories).This page will walk you through the Site Search setup, how to track Keywords on your internal search engine, and which reports Matomo (Piwik) offers.

Enable Site Search Tracking for your Website

To get started with Site Search tracking, login as the Super User or an Admin user and go to Administration > Websites. Here, you can enable or disable Site Search tracking for each of your websites.

Here is what the admin UI looks like for a particular website:

Site Search Tracking and Reporting - 图1

All Site Search reports are available under the main menu Actions > Site Search.

Tracking Site Search Keywords

An internal search is a specific type of action, and when an action is tracked as a Site Search, it does not count as a Pageview. There are three ways you can track a Site Search action:

Track Site Search using URL Parameters (default)

The easiest way to track internal search keywords, is to specify the URL parameter name that will contain the search keyword. By default, Matomo will read the URL and look for a parameter with any of the following names: q, query, s, search, searchword, k, keyword

The Super User can also specify the parameter names to use by default for all websites. Login as Super User, go to Administration > Websites, and look at the Site Search configuration at the bottom of the page.

Track Site Search using the Javascript trackSiteSearch() function

If tracking search results via the URL is not possible (for example if you use rewritten URL without query parameters, eg. /search/keyword) , or if you wish to also track the count of Search Results, you may use the Javascript function piwikTracker.trackSiteSearch(keyword, category, searchCount). Calling the function will record the search keyword, search category, and the count of results on the search result page. This can be used on Search Results pages, instead of calling piwikTracker.trackPageView().

Check out more information in the Javascript documentation for trackSiteSearch()

Track Site Search using the Tracking API (advanced users only)

Advanced users can also record Site Search requests using the Matomo Tracking API. See more information in the Tracking API Reference page. Specifically, look for the parameters ‘search’, ‘search_cat’ and ‘search_count’.

Tracking No Result Search Keywords

Would you like to benefit from the report “No Result Keywords”, listing all keywords that didn’t return any search result?

If you are using the “Track Site Search using URL Parameters (default)” setup, the only way to track the number of search results on the page is to edit the Javascript code, in the search result pages, to tell Matomo how many results are displayed. Once you have this number available in a Javascript variable, you can write:

  1. [...]
  2. var searchCount = 15; // set this value when rendering the search result page
  3. _paq.push(['setCustomUrl', document.URL + '&search_count=' + searchCount]);
  4. _paq.push(['trackPageView']);
  5. [...]

Matomo will then track for the site search query, the number of results, and will report all keywords with “zero” results in the “No Result Keywords” report.

Site Search Analytics Reports

Under Visitors > Overview, the total number of Site Searches is reported alongside the total number of Pageviews, Downloads, Outlinks, Events, etc.

Under Behavior > Site Search, you will find all the detailed reports, such as the Top Internal Searches:

Site Search Tracking and Reporting - 图2

You will also find the “Pages Following a Site Search” report, which displays the pages which are most searched for and clicked on in your search engine:

Site Search Tracking and Reporting - 图3

View the Detailed Searches for each Visitor

The Visitor Log & Real Time Widget will show the searches done by each visitor. In the example below, the visitor went to the Matomo.org homepage, searched for “javascript”, then “no script”, visited four pages, searched for “cookie”, visited one page, and finally searched for “server side”. Matomo lets you see in detail how visitors are using your websites and when during their visit they have executed a search:

Site Search Tracking and Reporting - 图4

Number of searches and keywords over time

The Visitors > Overview report will also show the number of searches and unique keywords:

Site Search Tracking and Reporting - 图5>

Understand How Site Search is Used to Find other Pages on your Site

The useful Transitions report will also show when Internal Search Keywords were used to reach the page being visualized. For example, in the screenshot below, you can see that there were five Internal Searches (on the left) that lead to the “/changelog” page (in the middle box). The searches were “changelog”, “add site”, “grouping” and “change servers”.

Site Search Tracking and Reporting - 图6

It is useful to know which keywords visitors search for to find a particular page. If, for example, you notice many people search for a particular page, perhaps that page is more important than you realize and could be showcased more clearly.

Tracking how people search your website is an easy way to find out exactly what your visitors want from you and your website.

Happy Site Search Analytics with Matomo!