Site search tracking for WordPress with Google Analytics

With just a little setup, Google analytics can track keywords and phrases entered into your WordPress site’s search box. By default, your search results will show up as regular page views which look something like /?s=Search Term&submit=Search. Using GA’s Site Search Tracking feature, however, you can filter these terms into the Behavior > Site Search section of the reporting interface in order to gain deeper insight into what your visitors search for on your site.

Set it up

Screen Shot 2016-09-06 at 5.43.29 PMTo configure site search tracking for a WordPress site:

  1. Log in to Google Analytics and click on Admin.
  2. Select the appropriate Account, Property, and View for your site at the head of their respective columns in the Admin interface.
  3. In the View column, select View Settings.
  4. Enable the Site Search Tracking option with the toggle switch.
  5. Set the Site Search Parameter field to “s” which is the parameter WordPress uses for search terms.
  6. Optionally, check “Strip query parameters out of URL.” This will make all searches show up in analytics with the same URL (“/?s=Search Term&submit=Search” by default,) making it easier to track total search volume in your other reporting views.
  7. Click Save to finish!

Now search data will be parsed out into the Site Search interface for all future traffic.

Advanced use

If you have a custom search form which filters using default or custom taxonomies, you can get further insight into visitors’ search habits on your site using Site Search Categories. In the same interface, enable Site Search Categories and enter a comma separated list of any taxonomy identifiers which may appear in your search queries. These identifiers will be the query_var for the taxonomy. For a custom taxonomy this is likely the taxonomy name, unless you’ve specifically replaced it. For tags and Categories it will be “tag” and “category_name” respectively. Again, you can optionally check “Strip category parameters out of URL” to keep all of your searches tracking as a single URL.

Now that you’re tracking your search terms, check out Google’s advice for interpreting it. To paraphrase my buddy Gahlord, analytics data is only useful if you’re using it make decisions.