Configuring an Adsense Account on Multiple Analytics Profiles

I know it sounds easy to achieve but it took quite a bit of fiddling around to figure out how to get my AdSense account to track properly on multiple Analytics profiles (the primary profile I’ve had running fine but when I wanted to track a secondary profile on a Google Analytics Dashboard it proved more difficult). I shall explain how I finally got it working, in this case on 2 WordPress sites (but the process can obviously be used for non-WordPress sites too).

  • If you haven’t already done so, you’ll need to set up an Analytics and AdSense account and link the 2 accounts. To do this click the link inviting you to do so in the home tab of your your AdSense account. If you have done so already there should be a link saying “View performance in Google Analytics” on the right of this page.
  • If you haven’t already done so set up Adsense ads on the relevant websites. It is important to add a small line of code to your Adsense banner code in order to track the right profile. All you have to do is to add this line:
window.google_analytics_uacct = "UA-xxxxxx-xx";

To the banner code near to top, so that the banner code looks something like this:

<script type="text/javascript"><!--
window.google_analytics_uacct = "ua-xxxxxx-xx";
google_ad_client = "ca-pub-yyyyyyyyyyyyyyyy";
google_ad_slot = "zzzzzzzzzz";
google_ad_width = zzz;
google_ad_height = zzz;
<script type="text/javascript"
(Where the xxxxxs are your ua number and the yyyyys are your Google AdSense ID number and the zzzzzs are your google ad slot details)
  • If you haven’t already, set up the Analytics profiles for the websites you want to track and enter the tracking code in the head of every page of the relevant websites and verify them in Analytics. FYI; for WordPress sites I use the plugin called Google Analyticator, within Analyticator you need to enter the UA tracking number but usefully you also have the option for the Google Adsense ID number. If you aren’t using Analyticator or WordPress you will need to add the below line to to top of your Analytics code:
<script type="text/javascript">window.google_analytics_uacct = "pub-xxxxxxxxxxxxxxxx";</script>
So that the complete code looks like this (where the xxxxxs are your ua number and the yyyyys are your Google AdSense ID number) – make sure you have the right ua number for each profile, please note the AdSense ID number remains the same of each profile you set-up:
<script type="text/javascript">window.google_analytics_uacct = "pub-yyyyyyyyyyyyyyyy";</script>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-x']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

  • If you are able to, use the old version of Google Analytics as it is easier to find things (the link to toggle is at the top of the page – but for how much longer nobody knows)! Edit each of the “Main Website Profile Information” settings and tick the “Yes, this profile should receive AdSense data” check box. One of the profiles will be your primary one and the rest will be secondary. When you tick this check box on any secondary profile a text area will appear saying “Paste this code at the top of any webpage in this domain that contains AdSense ads. Be sure to leave the Google Analytics tracking code at the bottom of your pages.
The code looks like this:
<script type="text/javascript">
window.google_analytics_uacct = "ua-xxxxxx-xx";
You just need to make sure that this code is in the head anywhere above the actual Analytics code (which should also be in the head). This is the funny bit: Do this on all sites INCLUDING the primary one (I know the documentation says you only need to do it on the secondary ones but it started working for me when I had it on the primary as well – it may not be necessary but it won’t hurt the primary if you have it on it there too anyway – at some point I will take it off and test).
  • That’s it… Now when I set this up it took me a few days to believe it was actually working i.e. until I got accurate click through information on both my Analytics and AdSense accounts on both profiles. Be patient it does work. FYI click testing your AdSense links yourself won’t usually be registered by Google and you may do so and think the code isn’t working… so you will have to wait for genuine clicks. Please note I think that click testing myself caused my Analytics to register the clicks but the value was always $0.01 – very strange.
Please note some of the above may be irrelevant but as I play with the code I’ll update this post and remove the irrelevant bits… But for now I’m just happy it works.

If anyone is having issue with this please let me know and I’ll take a look and help if I can. Similarly if you have any questions please enquire below.

Leave a Reply

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

Previous Post

Using Custom phtml Template Files Rather Than Static Blocks in Magento

Next Post

EU Cookie Law Implied Consent

Related Posts