Google Analytics Site Search Setup Guide

Est. Reading Time: 4 minutes

New Google Analytics Tracking Code SLI Setup:

1.    Starting from the “Analytics Settings” page, click “Edit” under settings, then click “Edit” again under the main Website Profile Information section. This will present the following options.

2.    Select “Do Track Site Search”

3.    Complete a Site Search on your website and view the resulting URL and find the keyword phrase you used as a test.  Identify the query parameter that immediately precedes your test query and insert it into the Query Parameter box as seen in the setup below.  Be sure to replace with your parameters versus what is in the example below.

4.    If you have categories, follow the same test and place your Category Parameter in the box below as well.

Google Analytics Site Search Setup Google Analytics Tracking Code for Results Hosted on SubDomain:

** Must be placed on every page on both the main domain and the search results sets.

<script type=”text/JavaScript”> var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”); document.write(unescape(“%3Cscript src=’” + gaJsHost + “’ type=’text/javascript’%3E%3C/script%3E”)); </script> <script type=”text/javascript”> var pageTracker = _gat._getTracker(“UA-789266-1″); pageTracker._setDomainName(“”); pageTracker._initData(); pageTracker._trackPageview(); </script>

Google Analtyics Tracking Code for Third Party Tracking:

Complete the steps listed above and follow the instructions listed below.

The following code must be placed on all pages on both websites.

<script type=”text/JavaScript”> var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”); document.write(unescape(“%3Cscript src=’” + gaJsHost + “’ type=’text/javascript’%3E%3C/script%3E”)); </script> <script type=”text/javascript”> var pageTracker = _gat._getTracker(“UA-642481-1″); pageTracker._setDomainName(“”) pageTracker._setAllowLinker(true); pageTracker._setAllowHash(false); pageTracker._initData(); pageTracker._trackPageview(); </script>

The action in the form must also contain an onsubmit event using the following code:


** Every link on either site that allows visitors to cross each domain including all search results must also contain the following code in the onclick event:

pageTracker._link(‘’); return false;

Ecommerce Setup and Tracking:

Access the “Edit Profile Information” configuration through the same steps as setting the Site Search.

Select “Yes, an E-commerce Site”

Google Analytics Ecommerce Setup

Select your currency and related settings.

You will need to embed the following GA Ecommerce Tracking code into your website’s ecommerce Confirmation Page.  This code will need to be integrated with your existing ecommerce platform and will have to dynamically extract the information either from the database or from variables that can be carried over from the shopping cart.

** This step will require programming knowledge and custom programming in order to extract the correct variables and build an array for instances where there may be multiple products.  The array will then dynamically add all the products and build the correct coding to deliver the information to Google Analtyics. If this step is not completed correctly, your ecommerce will not function.  You can not copy and paste the code below and have it function for your system.

<script type=”text/javascript”> pageTracker._addTrans( “order-id”, // required “affiliate or store name”, “total”, “tax”, “shipping”, “city”, “state”, “country” );

pageTracker._addItem( “order-id”, // required “SKU”, “product name”, “product category”, “unit price”,  // required “quantity”  //required );

pageTracker._trackTrans(); </script>

Example of Reports Available Once Setup is completed:

Google Analytics Site Search Example

Google Analytics Site Search Snapshot

Google Analytics Screenshot Site Search

Snapshots Google Analytics Ecommerce Reports

The reports above are only a few examples of the available reports.  You have the option to dig down on any of these and investigate peculiar or interesting information in much further detail.  I hope this has been helpful and if you have any questions, please let me know.




  1. media planning
    Posted October 22, 2009 at 6:53 am | Permalink

    Great advice. This should really help web designers keep better track of their sites.

  2. Posted November 16, 2009 at 7:07 pm | Permalink

    Those are some good points. But, with a lot of competition out there offering very similar items for free, it’s important to be unique, and really stress relationship building.

  3. Posted June 25, 2010 at 6:08 am | Permalink

    nice article. Do you have any idea how multiple parameters work? It says you can enter up to five Query Parameters, but how do they get applied? For instance, if I have ?q=&qq=me, does it enter “not set” for the search term or does it enter “me”? Same with categories. I can’t find any documentation on this, any insight is appreciated. Thanks!

One Trackback