How to Track Site Search Queries in Drupal

Being able to track search queries in Drupal can give you valuable insight into what your users want or need.

Let’s say for example your website only sells red bicycles, but you notice that users are always searching for yellow bicycles. This type of insight into what your users are searching for can be very useful.

In Drupal there are a few modules that can help you track keywords used on a search page. In this article, you’ll learn about a few of these modules and how to track searches using just Google Analytics

“Top search phrases” Page

Drupal out of the box already does some level of search tracking. As long as you’re using the core Search module; you can see the most popular search phrases by going to Report -> “Top search phrases”.

Fig 1.0

But be careful, this is not a good solution for long-term search logging. The data used on this page comes from the watchdog table (or database log). Drupal by default only keeps a certain amount of log messages in the watchdog table. So use this page to find out the “most recent” top search phrases and understand that the phrases will change depending on how long you keep the watchdog data.

Search Log Module

The Search Log module offers search logging for the core Search module or any module that implements the hook_search_info() hook. The module stores the log data in its own table, however, it allows you to clear out the logs from its adminstration page (Configuration -> “Search log”).

You can also configure the module to keep logs only for a certain amount of days. By default, it’s set to 0 which means it’ll keep the logs indefinitely.

Fig 1.1

The module also has a pretty cool dashboard that allows you to view all the logs and filter them by date. Just go to Reports -> “Top search terms”.

If you install the Google chart API module you also get some fancy charts on the page.

Fig 1.2

Zeitgeist Module

Zeitgeist, another Drupal module similar to Search Log, allows you to log searches and stores them in their own database table.

The module ships with a basic report page called “Zeitgeist report”. You can access it by going to Reports -> “Top search phrases” and click on the “Zeitgeist report” tab.

Fig 1.3

The module has a fairly comprehensive configuration page where you can configure the reports page and its custom blocks. Similar to Search Log, you can define how long the logs should be kept for, by default it’s set to indefinitely.

To configure the module, just go to Configuration -> “Search settings” and click on the “Zeitgeist settings” tab.

Fig 1.4

Google Analytics

Google Analytics can also be used to track site searches. Now, there are two ways you can configure GA to log site searches: using the Google Analytics module or within the web application itself.

If you’re using Drupal’s core Search module and the Google Analytics module, then go to Configuration -> “Google Analytics”, click on the “Search and Advertisting” vertical tab and check the “Track internal search” checkbox.

Fig 1.5

But you’ll also need to setup your GA profile to track site searches, go to this page for more details.

If you’re not using the core Search module, then you can have GA track site searches by defining a “Query parameter”. You configure all of this in the web application, not inside of the module.

For example, the search page on Web Wash is /search?search=views. The query parameter in this case is search, so all I did was define search as a query parameter and now GA tracks any parameter like ?search=views.

Fig 1.4

Go to the Set up and configure Site Search page for more details.


As with most things in Drupal you have a few options. If you’re using the core Search module and you want to view the logs within Drupal then look at Search Log or Zeitgeist. However, understand that both of these modules only work with the core Search module.

If you’re using Search API or Apache Solr Search then I recommend that you use Google Analytics. If you don’t want to use GA then have a look at Search API stats or Apache Solr Statistics.

Similar Modules

3 thoughts on “How to Track Site Search Queries in Drupal”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top