How to Track Site Search with No Keyword in the URL

Site search in Google Analytics requires that the search form passes keyword in the URL of as a query parameter. Google Analytics then uses that query parameter to parse the keywords and show it in Site Search report.

Tracking Site Search

Clicking on “Search” in above form results in the following URL

Google Analytics is configured to read the query parameter “s” as the parameter that contains the search keyword.

However, if your form does not pass the keyword in the URL then that becomes an issue. Here are few steps that will help you get your site search report event when the keyword is not passed in the URL. You should have access to your site’s code or have the web developer follow these steps

  1. The Search form passes the keyword via POST method (if it is not passing it via query string). This keyword can be grabbed on the final search result page via some coding (.net, php or any other programming language your sites uses). Grab the keyword and store it in a variable.
  2. Once you have the keyword in variable on the use that variable to construct a pseudo URL that passes this keywords in the query parameter. In order to do so modify the Google Analytics code on the search result page from
    _gaq.push([‘_trackPageview’, ‘searchreuslt.aspx?query=[keyword]’]);
    Where “searchresult.aspx is the name of your Search result page. If the name is different then use that name. “query” is the query paramter that is used to pass the keyword.
    _gaq.push([‘_trackPageview’, ‘searchreuslt.aspx?query=insurance’]);
  3. Set up your Google Analytics to read the query parameter “query” as the parameter containing search (see below).

Now you should be able to see your Site Search results in Google Analytics Reports.


1 thought on “How to Track Site Search with No Keyword in the URL”

  1. Another popular solution is to capture the search phrase using a JavaScript onclick event & pass it into Google Analytics.The downside of this approach is that depending on how fast the browser redirects, it might not be captured by Google Analytics but is another option if logging it on the search results page isn’t possible.

Leave a Reply

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