What is the best way to track, record or view search terms? Pretty much like the title says - What is the best way to track, record or view search terms when using the built in Search form?
We track search terms on buildwithcraft.com the same way we track all other site activity: using Google Analytics.

All you have to do is throw GA event tracking code into your search results template.

If you’ve upgraded to Universal Analytics/analytics.js, use this:



{% set js %}
    ga('send', 'event', 'Search', 'Search', '{{ query|e("js") }}', {'nonInteraction': 1});
{% endset %}
{% includeJs js %}


If you’re still on the old ga.js, use this:

{% set js %}
    _gaq.push(['_trackEvent', 'Search', 'Search', '{{ query|e("js") }}', null, true]);
{% endset %}
{% includeJs js %}


There are other ways to include the JS, of course. (In our case we actually have a blank analytics block right alongside other Google Analytics instantiating code in the layout template, and set this JS code by overriding that block on templates that have custom things to track.) This {% includeJs %} route is just the most unassuming.

With that code in place, you’ll be able to start tracking “Search” events from Behavior > Events in your Google Analytics dashboard.