Track AdSense Clicks with Google Website Optimiser & Analytics
I’ve always wanted to improve the profitability of my AdSense sites, but only until recently, have I been using Google Website Optimiser to find the most profitable ad placements. I encountered many errors, hopefully many of which I can help you to avoid.
My solution:
- Integrates Google Website Optimiser (GWO) with Google Analytics (GA), to track clicks and revenue from AdSense for each variation
- Uses GWO which can be placed on template pages, such as in WordPress, Joomla, Drupal or whatever you’re using as your CMS
- Affects your bounce rate (as it uses _setVar to segment based on the variation of the page and AdSense metrics - which cannot be done with custom variables… yet)
Getting started
1. Choosing Google Website Optimiser code
You need to create a GWO Multivariate experiment (makes GWO/GA integration a breeze and allows you to modify the ads, site-wide for consistency).
2. Installing the code
- Place the control, tracking and conversion codes all on your test page.
- Leave the section variations to later.
- Comment out the conversion code - you just need it on the page to pass GWO’s verification.
3. Customising Google Analytics
In order to segment the different variations in GA, you’ll need to add a couple of lines to your GA code:
if(typeof(utmx) == 'function'){ try { pageTracker._setVar(utmx('combination')); }catch(err){}}
Like so:
<script type="text/javascript"> </script>
Note the order that trackPageview and setVar are called in. Also note that I’m using setVar and not setCustomVar - You can’t easily use custom variables with AdSense metrics at this stage.
4. Adding Section codes around the AdSense
This is the part I struggled with. In order to change the location of your AdSense code, you must only put part of the AdSense code within the section code. Placing this code anywhere else resulted in GWO stripping the AdSense variables out (like google_ad_slot and google_ad_width).
I.e. Section code highlighted by stars.
<script type="text/javascript"><!-- google_ad_client = "pub-111111111111111111"; /* Name */ google_ad_slot = "11111111"; //--> </script> <script>utmx_section("Insert your section name here")</script> <span class="alignright"> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></span> </noscript>
5. Testing colours in AdSense with Google Website Optimiser (Not tested, yet…)
I haven’t gone this far yet, but I hope to try this out soon. My thinking is that you will have to define javascript variables in the site’s header and use those variables in specific AdSense code - the code that allows you to change the colours etc.
Once that’s done, you’ll be free to start testing and you’ll see cool results like this in GA:
I’m pretty certain you can use custom variables now. You can segment Adsense reports via Advanced Segments. So you can create an advanced segment based on your custom variable and apply it to Adsense reports in GA to see the impact. This won’t impact your bounce rate either _setVar() was changed a while ago to be a non-interaction hit meaning it shouldn’t impact your bounce rate.
http://code.google.com/apis/analytics/docs/concepts/gaConceptsOverview.html#gifRequestClassification
Hope that helps.
I was under the impression that you shouldn’t mess with Google’s adsense code. Even splitting it up for use with GWO could be a reason to have your account banned. Of course, if you’re a premium publisher they give you access to their API which allows you to change all the variables.
Did you ever take this post one step further and test colors, sizes, etc. like you talk about in step 5?
Hi Dave,
I’m not sure about the details of the AdSense policies, but it sounds like they don’t want you to manipulate the look of the ad block to game the system. Changing things like position of the ad, colours of elements and size (as long as it’s in the parameters they give you) should be fine. Again, I’m no legal buff, so it may be worth checking out.
Re: Step 5. I haven’t done that yet - haven’t had time yet. My solution, I envision will involve some simple Ajax with Jquery (and yes - it’s really simple).
If you’re interested, I’ll code it up, run some tests and make a post about it.
Super interested!
It’s tough to even get in contact with the adsense team to ask them. I’ve seem an “official” A/B test that uses a simple if/then javascript routine to split test adsense, but never anything like what you’re talking about. O spent all day Thursday reading up on optimizing adsense CTR with GWO and GA but there aren’t many people even talking about it.
Hey Dave,
I’ve been testing it, but it looks like it’s not working so well. I believe in order to make Ajax work with AdSense we need to have access to Ajax for Adsense:
http://code.google.com/apis/afa/
I’ve signed up in the hope that I’ll be accepted into the program.
In the meantime, the only other way I can see this working is through loading different Iframes or split testing Google Ad Manager slots that are filled with different AdSense Ads:
https://www.google.com/intl/en_US/dfp/info/welcome.html
I’ll see if I can whack something together when I have a moment (hopefully sometime this week).
Regardless, I don’t think they’re ideal solutions…
The only thing I could think of is manually creating a ton of ad units and then configuring a GWO page but that is far too manual of a process, not to mention pretty code-heavy.
I can’t quite wrap me head around getting this to work across a whole site too (I’m using wordpress) without the user experience being messed-up. Adsense units flying around with every page load would be like walking through a haunted mansion with furniture flying about!
Like I said before, thanks for taking whacks at it. There isn’t much info on the web about this sort of thing. You’d think Google would put something together since it’s for the benefit of them as well.
Dave! I think I’ve done it.
It turns out serving AdSense through Google’s own Ad Manager tool lets you use Google Website Optimizer on it.
I’ve yet to fully integrate it, test it (want to make sure revenue is reported through Analytics still) and post the solution.
Would you mind if I emailed you a link to it? (should be in my WordPress database)
PS. You WOULD think Google would help us test this stuff more thoroughly. I mean how else do you provide a consistent user experience (i.e. ads not showing every which way during a visitor’s session and repeat sessions). That’s been a major flaw of testing with the current setup.
PSS. There is one more solution involving Iframes which I might also explain in my post (if it works).
Absolutely! I’m still scouring the web for info pertaining to modifying adsense code. I’ve found where I can ask adsense policy clarifications, but the solution you’re hinting at sounds legit.
Hi Rob I’d love to hear what solution you came up with using doubleclick ads. Personally I find iframes a great solution since I can use php statements in my template to exclude it from showing on certain pages (contact,privay policy, etc) and it’s automatic insertion. By the way regarding the policy on modifying adsense code this may be of interest(and also getting full targeting with iframes)
“Please note that you are free to add HTML code or javascript in front or
below the AdSense ad code as long as you do you change the ad code itself.”
From http://geoland.org/2007/01/adsense-in-iframe/