Optimize Internal Site Search Conversion Rates with Google Tag Manager



Often overlooked, Internal Site Search’s importance shouldn’t be underestimated. Recently, as I was exploring our company’s website, I noticed that our internal search results weren’t as helpful as I anticipated.

I conducted a search on our site for “google analytics”, a term very significant to us at LunaMetrics. I was shocked to see that all the top listed results were blog posts.

While blogging is important to us, it’s also important for our visitors to know that we offer trainings around the country and Google Analytics services to clients. All the relative content we had created through our blog was coming back and actually overpowering our other results, hardly an ideal situation.

We, as marketers, do a lot to get people to our site. From search engine marketing to analysis of internal analytics, we make it a top priority to ensure our website is extremely visible across all channels of the internet. Why then does it seem that we tend to slack when it comes to internal search results of our own site?

Not being able to quickly see our Google Analytics trainings after my query was a definite problem. If you’re in a similar position, here’s how I sought out to address it.

Let’s Break Optimization into Two Steps:

  1. Checking to see if you have a problem
  2. Addressing your problem areas

Checking To See If YOU Have A Problem

The first step in checking to see if you have an internal search optimization problem is to create a list of terms you would like to test. The easiest way to do this is to export the list of site search terms from Google Analytics.

Once you have a list of site search terms take the most popular (we chose to do the top 25) and determine what your top results are. You can give this project to an intern (bad idea) or do it programmatically like we did!

After reading Michael’s recent blog post and talking over the problem with LunaMetrics’ Jon Meck, we came up with a solution. Using SEO Tools for Excel, we created a site search scraper. This Excel document uses the SEO Tools XPathOnURL function to crawl pages for specific content.

We used it to diagnosis issues with our internal site search, by crawling our internal search results page for the first result that appeared and storing it in the Excel file.

Internal site search varies depending on your website, so you will have to look through your own results in order to figure out where to pull your search results from. For us, we found that the 1st search result was always within the H3 tag. This is what we wanted to concentrate on. Once the file loads and the site scrape is complete, you will have a list of search results.

The next step is the important one. From the list of search results you need to identify problem areas, or areas where you think the top search result should actually be something else. As I mentioned before, our first problem area was “google analytics” which wasn’t returning results for either Services or Trainings. Once you have identified the problem areas, you are going to address them.

Addressing Your Problem Areas

There are many ways to address content problems with internal search. Depending on what you use for site search, you could dynamically change your search results so they better encompass the problem terms, or you could look for a new site search that would allow you to do so.

If you don’t have that option, you can try the method I tested, which involves using Google Tag Manager to fire suggestions every time one of these “problem terms” is queried, containing the information that you deem more relevant to your company.

I am favoring the GTM route because it still works even when you add more content to your site. If you are always adding new content to your site, you never know if something you just added suddenly becomes more relevant than the result you optimized prior to adding the new content.

Here’s the basic gist of how we’ll address the situation. A person arrives on the search results page, we’ll check to see if they searched for a keyword that we’re optimizing for, and if so, we’ll use GTM to insert a suggestion.

Before I discuss how to implement GTM, you should look at your problem terms and group anything that is similar together, as these keywords will become the terms that trigger your Tag Manager suggestion to fire.

After grouped, you need to generate a new message for each group that better promotes the more relevant content. For us, we included a brief description and HTML links to more relevant content. Here is what it looks like inside of the the suggestion wrapper:

Site Search Suggestion from GTM

We will be using a Lookup Table Macro inside of GTM, so we’re also limited to just 255 characters for this new message.

How to Implement

1. Create a Macro to pull the site search term from the URL. If your site search term doesn’t show up in the URL with query parameters, you may need to find a creative solution here. For us, it was as simple as using a URL macro and entering the site search parameter, “s”.


2. Create a Lookup Table Macro to match the search query term to the suggestion text. Check out this link to automate the Lookup Table Macro.


3. Create a Rule for when the page is equal to the Search Results page and where the Lookup Table has returned a value. This way it will only fire when someone searches for a term that we listed in the Lookup Table.


4. A Custom HTML Tag was made for the shell going around the search term suggestion. I modified the Expand Message example from this blog post about inserting Ads on your site through Tag Manager.

5. The Lookup Table Macro was inserted into the Custom HTML Tag in order to populate the message inside of the suggestion box.


6. Set the firing rule to be the Search Results rule we just created.

7. Lastly, you’ll want to add some sort of tracking to this, to see if your optimization was worthwhile. For us, we used a class on the links and a Link Click Listener to fire a Google Analytics Event every time someone clicked on our suggested links.

Make sure you test and debug as much as needed to get this box to look right, then Publish to your site!

After successful implementation of this Google Tag Manger Suggestion Box, here is what it looks like now when I search for Google Analytics.


Good luck with your own optimization and let us know what you are doing to stay on top of your internal site search in the comments below!

Jonathon is a former LunaMetrician and contributor to our blog.

  • Andrew Garberson

    Everybody like a good workaround. It’ll be interesting to see how this impacts conversion rate from the internal search results. Nice post, Jonathon.

  • Thanks, Andrew. Was really excited to see this the whole way through, from identifying the problem to finding a solution to putting together a blog post! It definitely will be interesting to see what kind of results come from this implementation.

  • I seem to be having an issue getting my Site Search data to GA. I added site search 1 week ago but still don’t have data. I contacted Google site search and they said I need to add the GA code to my http://www.plastics1.com/search.php page, however I am using GTM to do this…. could this be causing a problem?

  • @Mike –

    You need to set up Google CSE to make sure the search term someone typed in appears in the search results page url.

    For example, if I search for “plastic tubing”, the results pages should look something like:

    There is a setting in Google CSE that lets you specify a Query Parameter Name. This is a string to identify the search term someone used. In the above example, it’s the letter “q”.

    Whatever you specify here needs to match how you’ve set it up in Google Analytics (whatever you specified for the Query Parameter).

  • I do have both the CSE and GA set to use “q”. Am I understanding you correctly that the Theme I used for CSE where the results are ajaxed in is my problem?

  • @Mike – I’m not sure the exact settings in CSE, but Google Analytics is looking for the pageview to have the search term included on the URL as query parameter. You need to figure out how to make that happen using your site and your internal search engine.

    Here’s an article about Google CSE – https://support.google.com/customsearch/answer/1321536?hl=en

    And also a set of workarounds through Google Tag Manager –

Contact Us.

Follow Us




We'll get back to you
in ONE business day.
Our Locations
THE FOUNDRY [map] LunaMetrics

24 S. 18th Street
Suite 100

Pittsburgh, PA 15203


4115 N. Ravenswood
Suite 101
Chicago, IL 60613


2100 Manchester Rd.
Building C, Suite 1750
Wheaton, IL 60187