Track AdSense Clicks With Google Analytics

It would be cool if Google automatically tracked AdSense clicks into Google Analytics… But until they do, here’s a little bit of JavaScript code you can use to do it. You can then setup an AdSense click as a “goal” within the Analytics interface.

[code=javascript][/code]
This only works with Internet Explorer because of some limitations/bug with Mozilla. I’m too lazy to code a complicated workaround for other browsers (which would involve running JavaScript code whenever the mouse moves which seems really inefficient to me). Hopefully Mozilla will fix the bug (although it’s been pending for 2 1/2 years now).

Basically it will log an AdSense click as a pageview to a non-existent page (//www.digitalpoint.com/AdSenseClick in my case).

Update

I made a version of the code that will work with AdSense and/or Yahoo Publisher Network. You can find it over here.

79 thoughts on “Track AdSense Clicks With Google Analytics”

  1. Hi,

    Kewl: I have added the urchinTracker( ‘ fake rel URL’ ) to my existing IE clickthrough code so I’ll have the stats in my custom DB and in Google Analytics.

    I shall put this up on one mirror almost immediately.

    Thanks,

    Damon

  2. Ok, well I tried it with YPN and my stats finally updated and nothing shows.

    Is this wrong?

    if(elements[i].src.indexOf(‘overture.com’) > -1) {

  3. The code would need to be a little different because Yahoo ads don’t set the browser status to “go to whatever”, so I would just take out the logic that tests for it.

  4. Well, I’m sure Shawn is right… but it’s Greek to me…hehe. I think he’s talking about removing the “if”, but it’s hard to test something with clicking it or waiting for google to update sats.

    If anyone has a working example, I would appreciate seeing it. I would REALLY like to have this to work with YPN.

    Thank you.

  5. You can test it (make clicks yourself) by changing the AdSense ID to ca-test. Oh wait… that wouldn’t work for YPN… hahaha… no idea what YPN’s test ID is.

  6. Thanks for the script Shawn! I looked at my stats for the past week and looks like its not accurate comparing with Adsense account – do you know why?

  7. Great.
    But I found that it works well for the first click, but when return back to the history page, the following clicks can not be tracked.
    Can you tell me how to figure it out?

  8. This doesn’t really work all that well. First of all, if someone clicks back, chances are clicks will not register.

    And this is not a Firefox bug, the reason it doesn’t work with firefox is “change status text” is off by default.

    Options -> Content -> Advanced

    Too bad, because this could be used to prevent clickfraud if it worked.

  9. Worked great for me for first month or so, but the other day it stopped recording roughly 90% of my clicks. Anybody else seen this? My .js file is on a seperate domain, but this wasn’t a problem before. And help would be great. thanks.

  10. I have a question on what is being tracked as well. We are within 10% of the numbers reported by adsense, but only if we add in the number of hits from the googlebot client. Tracking only the IE hits, it ia much further off. Is that correct? Does the googlebot follow in the adsense links?

  11. If you just want to know how many AdSense clicks you have received you may want to check out the metrics package at performancing.com.

    Performancing.com Metrics counts AdSense clicks (incl. adlinks) and it also shows the goal of the clicks in the outbound links page.

    Performancing.com Metrics is a pretty complete free statistics package. Not as powerful as Google analytics but it has hourly updates and a faster overview.

  12. Im trying to track adsense clicks but Im getting no window.status text appearing in the status bar. Could anyone tell me why this is. If theres no status bar text when I hover I cant get the url of the clickers. It does appear when I hover over other links on the site

  13. Thanks for your help but, if it doesn’t work on Firefox bro’ … i am in trouble. Now, huge people huge firefox …so

    is their any way that i can get the same service?

    Now time to update it and make it computable for mozilla.

    thanks once again

  14. What interests me the most is the geographical location of people who click, and the exact ads (site link) that was clicked, this may give a hint about who needs what and where, always help for targeting and keywording !!

  15. Four years since the post was made and still the article ROCKS! your awesome man.
    BTW thanks for sharing the codes

  16. This is exactly what I’ve been looking for, I found the script in another blog as well and the content is quite similar to this (even the comments). Anyway, thank you for sharing

  17. What interests me the most is the geographical location of people who click, and the exact ads (site link) that was clicked, this may give a hint about who needs what and where, always help for targeting and keywording !!

  18. So does this code now works with firefox or not? Someone said he found an updated version that does, can anyone post a link to it please?

Leave a Reply

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