I have multiple sites in my Google Analytics, and under the content section, adsense revenue per page is only visible for one of the sites. The rest of the sites in my Google analytics do not display what page the AdSense revenue came from.

Is this a known bug? Has anyone had this? Or do I need to configure something else?

Here is how I currently do this.

It is constructed as part of a php string, but the idea is the same. See the first 2 lines of this function. And the rest of the function displays traditional analytics snippet.

  $str = '';
    if($production === true)
        $str.= '<script type="text/javascript">'."\n";

        $str.= 'window.google_analytics_uacct = "UA-9425856-20";'."\n";

        $str.= 'var _gaq = _gaq || [];'."\n";
        $str.= '_gaq.push(["_setAccount", "UA-9425856-20"]);'."\n";
        $str.= '_gaq.push(["_trackPageview"]);'."\n";

        $str.= '(function() {'."\n";
        $str.= ' var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;'."\n";
        $str.= ' ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";'."\n";
        $str.= ' var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);'."\n";
        $str.= '})();'."\n";

        $str.= '</script>'."\n";
    echo $str;
  • Does anyone know if this works. I am having trouble getting my adsense to register on all my analytic accounts.
    – user6617
    Commented Apr 6, 2011 at 11:04
  • @Adam I tried to implement the answer below, but it still does not work for me unfortunately. Anyone else? :)
    – Genadinik
    Commented Apr 17, 2011 at 4:16

1 Answer 1


You need to add an additional snippet of code to your non-primary domains:

<script type="text/javascript">
 window.google_analytics_uacct = "UA-XXXXXX-X";

It needs to be placed above the other GA and AdSense code. The "UA-XXXXXX-X" should be replaced with the same GA account number used in the GA code.

  • @Ewan Unfortunately that didn't work.
    – Genadinik
    Commented Apr 17, 2011 at 4:56
  • Can you post an example of the code you're using? Commented Apr 17, 2011 at 12:38
  • @Ewan I just posted the snipped that is in my code. Thank you for following up :)
    – Genadinik
    Commented Apr 17, 2011 at 16:45
  • Try splitting up your code and putting the window.google_analytics_uacct bit just below the opening <body> tag. Then put the GA tracking code right at the bottom of the page next to the closing </body> tag. I know that GA suggests putting it in the head section but it is possible to put at the bottom as well and is sometimes needed for the AdSense tracking to work. Commented Apr 18, 2011 at 1:59
  • Did this change make any difference? Commented Apr 19, 2011 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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