AdSense not working in Analytics – reporting all zeros

For some time now I have used Google AdSense. For about the same amount of time I have used Google Analytics. You are supposed to be able to link the two accounts so that Google Analytics can show you your AdSense data and statistics in greater detail. I was able to get my AdSense and Analytics accounts to link, but Analytics would never actually track any AdSense data (i.e., it would always show all zeros).

I did a ton of web searching to figure this out. However, although all of the sites/forums always agreed on the same fix, the fixes never worked for a large group of people (including me), and no other fixes were ever posted – until I found one last week. The user sonrias2001’s comment at (a little more than half way down the comments on the 7th page) gave me the answer that worked. That user’s comment didn’t even get much acknowledgement by the others, but it works. Here the overview of how to fix the problem. Only one step – add the following line in the JavaScript for each ad unit, near the top of each ad’s code block (using your own domain name instead of mine, of course).


Note that previously I had already added the following line of code as well (per the suggestions of all the other “fixes” that didn’t actually work). The following line of code therefore might not actually be necessary, but it may be possible that it is needed in addition to the fix above. You may as well add both lines of code just to be safe.

    google_analytics_uacct = "UA-xxxxxxxx-x";

If that was all confusing, hopefully this will clarify. In the end, my ad code for each ad on my pages changed as follows, the top showing the old code and the bottom showing the new fixed code (fill in the x‘s with your actual account-related numbers):

Note that I use the domain name “” for the google_analytics_domain_name variable. I used the “.” in front of the domain because that is what my Analytics code used for its domain name setting. It is likely that yours will not include the leading “.” (just check what your Analytics-generated code has for its setting and then match that).

4 thoughts on “AdSense not working in Analytics – reporting all zeros”

    1. Not sure what the difference is between using the “.” and not using it. Just follow whatever Google Analytics tells you to do when you have it generate your code. Sorry I don’t have more info about this.

Leave a Reply

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