Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a Custom Search Engine that I've created with AdSense. I've put that search engine as a site search in my Google Sites page. I've connected both the Custom Search Engine and the Google Site to my Analytics page via their settings pages.

Now, I'm trying to get Analytics to show me the AdSense for Search statistics. I've managed to connect the Google Sites page, to the Analytics, and I can see the search statistics in the Analytics as well. But I can't get it to show the actual AdSense for Search statistics from the Custom Search Engine.

How can I configure everything so I can get the AdSense for Search statistics of my Custom Search Engine in my Analytics page?

share|improve this question

2 Answers 2

Unfortunately it looks like for the moment Google Analytics does not support Adsense for Search:

Google Analytics only records data for AdSense content ad units, and doesn't include link units, search boxes, mobile ads, or any other AdSense products.

share|improve this answer

To get Google Custom Search terms to show up in Google Analytics, you need to have the custom search submit URL parameters to your site that Google Analytics can read.

The code for the search box on my site looks something like this:

<form action="/search" id=search-form>
    <input type=hidden name=cx value="partner-pub-123456789:987654321">
    <input type=hidden name=cof value="FORID:10">
    <input type=hidden name=ie value=UTF-8>
    <input type=text name=q size=16 placeholder=search>
    <input type=submit value=Search>
</form>

You would have to replace the partner-pub id with your own custom search id. Note that I'm not using any of the JavaScript that Google gives you by default to show the search results in a lightbox on the current page. When I use that form, it causes the search to submit back to my site at the url:

/search?cx=partner-pub-123456789:987654321&cof=FORID:10&ie=UTF-8&q=search+term

The /search page has both the snippets for Google Analytics and Google Custom search on it. The custom search snippet is:

<div id=cse-search-results></div>
<script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 800;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>

which instructs it to write the search results into the empty div named cse-search-results.

Because the search term is in the q parameter, Google Analytics also picks up on it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.