Configure Google Analytics Site Search

If you already have a Google Analytics account, you can configure Analytics Site Search reports from within Custom Search.


To enable Google Analytics Site Search, you must add the Google Analytics tracking code to your site.

Configure Google Analytics Site Search reports:

  1. On the Custom Search Control Panel, on the left-hand menu, click Statistics and Logs, and then click Google Analytics. This page will display any Google Analytics profiles associated with your Google Account. (Don’t have a Google Analytics account? Get one here.) If you can't see a profile you're looking for, it may be that the admin of that profile hasn't given you admin access to it.
  2. Click Edit next to the profile you want to use.
  3. Make sure to check the Enable Google Analytics site search box.
  4. In the Query parameters box, type the query parameters you want to use. Please enter only the word or words that designate an internal query parameter such as "term,search,query". Sometimes the word is just a letter, such as "s" or "q". You can provide up to five parameters, each separated by a comma.
  5. (Optional) If your search engine includes refinements, type the category parameter in the Category parameters box.
  6. Click OK.

Your page should now contain both the Custom Search snippet and the Google Analytics tracking code, like this:

      <!DOCTYPE html>
      <html>
      <head>
        <title>Example</title>
      </head>
      <body>
        <!-- Paste your CSE code snippet (for search results) here. -->

        <!-- The following is your Google Analytics setup code. -->
        <script>
          var _gaq = gaq || [];
          _gaq.push(['_setAccount', 'UA-12345678-1']);
           _gaq.push(['_trackPageview']);

          (function() {
            var ga = document.createElement('script');
            ga.type = 'text/javascript';
            ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www')
                          + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(ga, s);
          })();
        </script>
      </body>  
      </html>

You’re done. You can now see Site Search reports in Google Analytics. Note that it may take several hours before data is available for viewing.