Google Analytics Site Search with Custom Search Engine


“Why isn’t my Custom Search Engine working with Site Search?”

Since I had never used Google’s Custom Search Engine before (shame on me), my answer was:

“Gee, I don’t know, let’s look at the instructions.”

But the instructions were nowhere to be found. The truth is, it’s so easy, you just might miss it.

So I took a look. Site Search was turned on. Check. The Custom Search Engine script was on the page. Check. Results are being displayed. Check.

So what was the problem?
Custom Search Engine
I didn’t notice it at first. The results were being hosted on Google.

In order for site search data to be processed by Google Analytics, you need to bring them back to your site. So in your CSE control panel, under Code, make sure you selelct the iframe option and follow the instructions provided (which, as usual, just involves copying and pasting a little bit of JavaScript.)

Now, at this point you might ask “What the heck is an iframe and how do I do it?”

It is just the term that describes the technique used by Google to get their search results inside your page. Don’t be afraid. There isn’t any additional iframe-related implementation that you have to do.

Oh, and make sure that the new page you create for the results is also tagged with your GATC (Google Analytics Tracking Code.)

That’s it. See, I told you it was easy.

John is a former LunaMetrician and contributor to our blog.

  • Why is it that Google does not put this in the help information. Thank good ness I found this I have been trying to make this great feature work and it just would not. I can not wait to see the report tomorrow since this will greatly help me refine the site based on user input. Thanks for the post and i am glad to have found it.

  • THANK YOU! I’ve been struggling for days to figure out why Google Analytics wasn’t showing our custom search engine results!

    You’re an angel. Now, tell me why this information isn’t on Google’s extensive help pages.

  • I agree with the comments above. The analytics help makes it seem just a little too simple. THis really should be in there, thanks for writing it down!

  • How can I use the overlay and still get the search terms?

  • Karsten,

    I’m not sure what you mean by using the over and still getting the search terms. If you can give an example, or try to explain it differently, maybe I’ll get what you’re asking.



  • I still don’t get this.
    I have a search engine that is on my site. It searches different site (excluding my own site). I want to be able to see what my users are searching for.

  • Also, does your search engine and your analytics need to be under the same google account?

  • The search engine and analytics do not need to be under the same account. As along as you select display the results in an iframe, it should not matter that it searches a different site. Make sure you have the Google Analytics Tracking Code on the results page, however.

  • rio

    Hello, i’ve pasted all the iframe codes in my wordpress based site. The Google CSE works well, but I can’t get the result in GA. I am sure the query term is correct. Does it matter to the search result landing page, which on my site is index.php instead of search.php?


  • The name of the page should not matter.

    If the site is then it looks like the view of the results page is being correctly submitted to Google.

    My best guess is to check in the Google Analytics reporting interface, under the “edit” for the profile and make sure Site Search is turned on, and the query parameter is set to “q”.

    Sorry if that is not much help,


  • rio

    Thanks John,

    Yes, GA query parameter is set to “q”, Do not strip query parameters out of URL, default page is index.php and no excluded URL query parameters.

    I doubt it’s because of i changed something in the iframe searchbox code, I wanted to take off the ugly search button, is that a problem?

  • rio

    all the greater than symbol is taken off in the following code:

    <form action=”” id=”cse-search-box”
    <input type=”text” name=”q” size=”31″ /
    <input type=”hidden” name=”s” value=”Search” /

    <input type=”hidden” name=”cx” value=”008533982481158292571:4ril6chsahq” /
    <input type=”hidden” name=”cof” value=”FORID:11″ /
    <input type=”hidden” name=”ie” value=”UTF-8″ /
    <script type=”text/javascript” src=”” </script </div

  • rio

    sorry, there shall be another line:
    input type=”hidden” name=”submit” value=””

  • Since you are not stripping query parameters check the Top Content report. Then search for q= to see if it is coming through.

    It should be since the utm.gif request was being sent to google for the results page.

    If that doesn’t help, try posting on A lot more people will see it there and maybe someone will catch something that I missed.


  • Pingback: Web Analytics TV with Avinash and Nick - Google Stuff()

  • Pingback: Web Analytics TV with Avinash and Nick « Analytics Expert()

  • Pingback: Web Analytics TV with Avinash and Nick | Rodney Payne()

  • Pingback: 互联Θ时代 » Blog Archive » Web Analytics TV with Avinash and Nick()

  • Very nice this option. Never read a thing about this until now. Google Analytics tracking script is just an other piece of javascript. Thanks to teach something new.

  • this was so helpful!!…”Oh, and make sure that the new page you create for the results is also tagged with your GATC (Google Analytics Tracking Code.)”
    why soesn’t google anal-ytics post this?

  • Robbin

    Well, John (who wrote this post a long time ago) also revised the GA Documentation to reflect some of these issues. But those kind of comments, “Oh, and be sure… ” etc tend to work better in a blog — Robbin

  • Pingback: Aitir Google Lab » Web Analytics TV with Avinash and Nick()

  • Pingback: Web Analytics TV with Avinash and Nick | Analytics Expert Blog()

  • thanks for sharing this. we have come to know some this new about google analytic

  • Yeah, in the way google collects the search queries for your site and it will increase your website visibility on the Google search Engine. Having site google custom search on your website is really a better idea, if you are depending upon the google search engine

  • well i m totally agree with you my friend & it also solve my problem too, as its just simple to understand, about the tricks of analysis. thanks for facing us some new face of google.

  • as its always to understand Google & its analytic, but while reading this google, i can say you solve atleast my some problem regarding this,

  • Pingback: Web Analytics TV with Avinash and Nick | Google Caffeine SEO()

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