Google Analytics Site Search Tracking Guide [All URL Formats]

Site search is one of the most important elements on your website which helps you analyze your customer needs.

It’s also a good way to enhance user engagement esp. for ecommerce sites. But capturing site search terms may not always be an easy task.

In this article, we’ll be looking at a whole lot of things related to google analytic’s site search feature. So without further ado, let’s get started…

Google Analytics Site Search Feature


How Does Site Search Tracking Work & Ways To Properly Setup in Google Analytics?

Let’s first understand how google analytics captures site search terms by default.

In fact, just by placing the analytics code on your website doesn’t enable Google Analytics to track site search terms. There’s one more thing you have to enable to get it going.

Here are the steps to properly set it up:

  1. Go To Admin & Select a VIEW from the dropdown.
  2. Go To View Settings (& Scroll down a bit)
  3. Enable the Site Search Tracking feature.
  4. Enter the query parameter, (say ‘s’) click Save.

And it’s done..!!


So, How Does Google Analytics Knows When to Track Search Terms.??

The way this works is

  • On every page load, Google Analytics will check the URL & the parameters.
  • If the parameter matches the one you mentioned in the view settings > site search feature, google analytics will start capturing various site search metrics for that session. Such as
    •  Sessions with Search
    • Avg. Search Depth
    • Unique Searches 
    • & more…

So, even if you manually type the query parameter on the page, say & hit refresh…

Google Analytics will think it’s a site search & will capture the “black shoes” terms along with its related site search metrics.

Btw, its good way of testing if your site search works or not.

NOTE: Site Search Data Prior To Enabling the Feature WON’T Be Reflected in Google Analytics. So Make Sure It Is Done At The Initial Setup.

List Of All The Site Search Metrics Available In Site Search Reports.

Once Everything has been set up correctly, the reports will get populated in the Behaviour > Site Search section in google analytics.

As per Avinash Kaushik, here are some of the questions answered through the site search reports.

  • What is the Frequency of Site Search Usage?
  • What are the Pages from where the Users Initiate Searches?
  • Are Users satisfied with the Search Results?
  • How Different Groups of Users Search Your Site?
  • What is the business outcome if users search on your site?

Here are some of the site search metrics available.

  • Sessions with Search
  • Total Unique Searches
  • Results Pageviews / Search
  • % Search Exits

& Here are some of the dimensions

  • Site Search Status
  • Start Page
  • Destination page
  • Search Destination Page

Here’s the full list below:

Dimension/Metrics Description
Site Search Status A boolean, either Visits With Site Search or Visits Without Site Search, to distinguish whether internal search was used in a session.
Site Search Category The category used for the internal search if site search categories are enabled in the view. For example, the product category may be electronics, furniture, or clothing.
Start Page The page where users initiated an internal search
Destination Page The page users immediately visited after performing an internal search on the site. This is usually the search results page.
Search Destination Page The page that users visited after performing an internal search on the site.
Sessions with Search The total number of sessions that included an internal search.
Total Unique Searches Total number of unique keywords from internal searches within a session. For example, if "shoes" was searched for 3 times in a session, it would be counted only once.
Results Pageviews / Search The average number of times people viewed a page as a result of a search.
% Sessions with Search The percentage of sessions with search.
Search Depth The total number of subsequent page views made after a use of the site's internal search feature.
Avg. Search Depth The average number of pages people viewed after performing a search.
Search Refinements The total number of times a refinement (transition) occurs between internal keywords search within a session. For example, if the sequence of keywords is "shoes", "shoes", "pants", "pants", this metric will be one because the transition between "shoes" and "pants" is different.
% Search Refinements The percentage of the number of times a refinement (i.e., transition) occurs between internal keywords search within a session.
Time after Search The session duration when the site's internal search feature is used.
Search Exits The number of exits on the site that occurred following a search result from the site's internal search feature.
% Search Exits The percentage of searches that resulted in an immediate exit from the property.
Site Search Goal Conversion Rate The percentage of search sessions (i.e., sessions that included at least one search) which resulted in a conversion to at least one of the goals.
Per Search Goal Value The average goal value of a search.

Reasons Why Your Site Search Doesn't work & Ways To FIX It.

Well, there’s always something in google analytics which doesn’t work as expected & one of them is site search tracking.

When the user searches for any keyword in your internal website site search, the URL pattern is generated.

This URL Pattern varies for different types of website, & it depends on your CMS.

Sometimes even after the successful search, the Search URL may or may not contain the Query Parameter or even worse, the Search Term itself!!

But Remember, You can always have a hack around it.

Google Analytics has the option to track the site search, ONLY IF you have the Search Term in Query String Parameter of URL.
OR‘, etc


There might be several reasons but they are mainly categorized as follows:

  • Site Search Term in present in the URL
    • As Query Parameter
      • Single Term
      • Multiple Term
    • Not As Query Parameter
      • Single Term
      • Multiple Term
  • Site Search Term NOT present in the URL
Google Analytics Site Search Tracking_Hierarchy

1.) Site Search Term Is Present in the URL: As Query Parameter

If the URL contains site search term as query parameter & still the reports are not getting populated, then check the following steps.

1.) Choose Correct View & Turn on Site Search Feature.

Make sure to choose the correct view & turn on the site search feature.

After turning it on, add the search query parameter, in the last case it would be ‘s’

So for single Site Search Terms like

  • ?d=desktop&search-term=facebook+custom+events‘ it would be ‘search-term’
  • ?q=facebook+custom+events‘ it would be ‘q’
  • & so on..

It doesn’t matter what comes before the ‘?’ , if your search term is in the query string.

IF you have multiple Site Search Terms

  • ?d=desktop&search-term=facebook+custom+events‘ it would be ‘search-term’ & ‘d’
  • ?q=facebook+custom+events&page=/‘ it would be ‘q’ &’page’

You can enter every term with “,” in between. (search-term,d or q,page)


2.) Check if the Google Analytics Hit contains the URL parameters.

You have to ensure that the google analytics code fires when the URL contains the search parameter. To make sure that the analytics will capture the search term, do the following check.

Open your Browser Debugger by pressing Ctrl+Shift+C (windows) or  Command + Option + I (MAC)

Do a search > Go To Networks Tab > Filter GA requests by ‘collect?‘ & check if the variable “dl” in the pageview hit contains the search term in URL Query string parameters.




If it doesn’t…

then ask your developer to retain the query parameters, you have the option to strip it out in analytics too.

If you don’t see the pageview hit request, then check if you have installed GA code on search results page.

3.) Avoid Redirects if possible.

2.) Site Search Term Is Present in the URL: NOT As Query Parameter (Single Term)

Kind of like ‘/search/[KEYWORD]’…

Then, it is obvious that google analytics site search won’t work just by enabling it in View Settings.

There are 2 ways to get around with it

  1. Use Advanced View Filter.
  2. Modify The URL to add the Query Parameter.


1.) Using Advanced View Filter

Go To View > Filters > Select Custom > Select Advanced Checkbox.

In the Field A — > Extract A

  • Select Request URI
  • Enter Search URL Format

Eg: If your user searches for ‘facebook events’ & your URL is of type

  • “”   then enter /search/(.*)
  • “”  then enter /search-keyword/(.*)
  • “”  then enter /find/(.*)/search

In the Output To –> Constructor:

  • Select Search Term
  • Enter ‘$A1’


Google Analytics Site Search Filter


Note: Select Request URI in Field A  –> Extract A (I forgot this in the gif :/)

Click Save & You’re Done.


2.) Modifying the URL to contain the Query Parameter.

So in simple words, if you have the URL like ‘{Keyword}

You can simply modify it & send it to analytics as ‘{Keyword}’.

Now you can enter ‘q’ parameter in the GA site search & start tracking.

Check out the method described below.

3.) Site Search Term Is Present in the URL: NOT As Query Parameter (Multiple Terms)

So, if you have a site where search URL has one or more site search terms in the URL in a format like

  • Location+Service
  • Category+Sub-Category
  • & so on..

we can use GTM to modify the URLs & send it to Google Analytics with site search query parameter.

Lets, take an example



If you are using GTM, you can create a Custom Javascript variable named ‘Modified URL’ & use it to fire Analytics Pageview.

In the below code, enter the URL format as ‘{city}-{service}’  the output would be



Site Search URL Tracking in Google Analytics

Then you can simply use the site search option & enter ‘city’ & ‘service’.

Follow the below steps if you are using GTM.

Step – 1:

In GTM, Create a Custom JS Variable (Modified Search URL)  & paste the following code.

Custom Javascript Code: (Modify the URL variable to match your search format)

You can use the above script for variety of URL formats

  1. /search/newyork/gyms  —-> Format: /search/{city}/{service}
  2. /search/newyork/gyms/premium —> Format: /search/{city}/{service}/{membership}
  3. /search/newyork-gyms/premium —>Format: /search/{city}-{gyms}/{membership}
  4. etc


Note: You can use any named variable. 


Step – 2:

Create/Modify Your Analytics. In the Fields To set options, enter the page & the value as the Custom JS variable.


Site_Search_URL_Modification - Google Analytics


Step – 3:

You can use All Pages or Only search pages trigger.

Note: The Modified URL will only be sent when the actual search URL matches the Search URL format you inserted. On the rest of the pages, it will send the normal URL.

Make sure to debug if your trigger is all pages. (Test Image)



4.) Site Search Term Is Present in the URL: One As Query Parameter & Other In the URL (Multiple Terms)

So, If your site uses IP tracking & When the user searches for “Best gyms in new york”  & URL is like


In this case, you’ll have to use

  • Advanced View Filter &
  • Enable Site Search Tracking & Enter The Parameter.


  • Modify the URL to Query parameter &
  • Enable Site Search Tracking & Enter The Parameter.

5.) Site Search Term Is NOT Present in the URL

If you have POST based search on your website,  you can take help of your developer to pass the search term as the query parameter.

For Eg:

Search URL : to

Modified URL:

Once you have the query parameter you can implement our normal site search tracking method.

Other method you can use is to ask the developer…

  1. To pass the search term in a javascript global variable.
  2. Then you can, fetch it as a variable in the GTM.
  3. And add it as a parameter to the page variable before sending it to Google analytics. (check the previous GTM method which we used)

How To Strip Query Parameters in the Analytics Reports?

In your Google Analytics reports, what URL format do you prefer??


Page Pageviews
/search/ 12


Page Pageviews
/search/facebook+events 6
/search/google+analytics 4
/search/how+to+do+analytics+audit 2


If you prefer the first one & you are using Query Parameters, you can simply check the box in site search settings.

If not…

Then create view filter > Search & Replace & paste the following as per your URL format.



Important Points:

  • Make sure to check the URL in the console, if it has the Query parameters.
  • If you are using one or more search terms in the URL, make sure to input the same format in the GTM url variable.
  • Lastly, comment if you have any doubts or I have missed any URL format. 🙂


More Awesome Articles…

Super Guide To Enhanced Ecommerce Tracking via Google Tag Manager [2018]

Automated Cost Data Import – Facebook To Google Analytics

500+ Dimensions & Metrics in Google Analytics [FULL LIST]

Ritwik is a Web Analyst & Product Marketer. He loves to write technical & easy to understand blogs for Marketers & Entrepreneurs. Focused on Google Analytics, Facebook Analytics, Tag Management, Marketing & Automation Scripts & more. Google Certified Professional. A Firm Believer in Teaching -> Learning -> Growing. :)

One comment

  1. Hi Ritwik,

    thanks for his post. I had already set it up and was waiting for results. After a couple i noticed the search pages does show data, i got a searchfield on almost all pages. When i click one page i can see the search terms being used on that page. However when i use the Search Term link on the left, sometimes it does show data and other times it doesnt. When it does show the data, it shows 19 hits and shows 1-10 rows, when i than want to view the other rows suddenly all data is gone and its back to 0???

    Say i click the index page / than after that sometimes it does show the queries and othertimes it doesnt seem to work. It looks like its very buggy or something. Im no guru at this and hardly understand all of this. I just tried this today and see if this could help us. The site isnt really published or given any social appearance, no traffic at the moement.

Leave a Reply

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