Friday, November 18th, 2005Friday, November 18th, 2005

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.

<script type="text/javascript">
// by Shawn - http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html
// Put this at the bottom of the page (after the last AdSense block)
	
function adsense_click() {
	if(window.status.indexOf('go to') == 0) {
		urchinTracker ('/AdSenseClick');
	}
}
	
var elements;
if(document.getElementsByTagName) {
	elements = document.body.getElementsByTagName("IFRAME");
} else if (document.body.all) {
	elements = document.body.all.tags("IFRAME");
} else {
	elements = Array();
}
	
for(var i = 0; i < elements.length; i++) {
	if(elements[i].src.indexOf('googlesyndication.com') > -1) {
		elements[i].onfocus = adsense_click;
	}
}
</script>

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 (http://www.digitalpoint.com/AdSenseClick in my case).

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

77 Responses to “Track AdSense Clicks With Google Analytics”

  1. Ray Says:

    Could this be modified (easily) to work with YPN?

  2. Shawn Says:

    Yeah… could work with YPN easily as well.

  3. AdMoolah News and Views » Google Analytics Update Says:

    […] Shawn at digitalpoint noticed the same thing and came up with a JavaScript hack to partially fix this. The reason I say “partially” is that it only works for visitors using Internet Explorer. I have included this JavaScript on one of my sites, but I have no idea when I will actually be able to see the results. […]

  4. Damon Hart-Davis Says:

    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

  5. Google Adsense + Analytics - S-O-S SEO Blog Says:

    […] Hier entlang geht es zum Forenbeitrag Track AdSense Clicks With Google Analytics. […]

  6. aaron wall Says:

    a friend of mine modified the code from Adsense Click Pepper to uses mouse cursor position prior to page unload to help decect AdSense clicks in Firefox.

    http://www.seobook.com/analytics/astrack.js

  7. Ray Says:

    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) {

  8. Shawn Says:

    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.

  9. Ray Says:

    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.

  10. Shawn Says:

    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.

  11. DerAdBlog » Blog Archive » AdSense Klicks loggen mit Google Analytics Says:

    […] Hier der Code: // by Shawn - http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html // Put this at the bottom of the page (after the last AdSense block) […]

  12. Track AdSense Clicks With Google Analytics: Blog Tips at ProBlogger Says:

    […] Shawn from Digital Point has developed a piece of javascript that will allow those AdSense publishers who use Google’s Analytics to Track their AdSense Clicks. The stats it gives should shed a bit more light on what pages convert best for Adsense clicks, what sources of traffic click ads more etc. […]

  13. Randy Charles Morin Says:

    You are too cool! Thanks!

  14. Track your adsense clicks » Online Business Tips at Metrobisnis Says:

    […] - Shawn (Digital Point) , read more… - SEO Book, Read More… […]

  15. Max Says:

    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?

  16. Shawn Says:

    Because it doesn’t work with Firefox users (see note about Mozilla bug).

  17. Используем Google Analytics для кликов AdSense » Ну и Ну! ру Says:

    […] 1) Первую версию берем у Shawn Hogan (недостаток не работает в IE) 2) Вторая доработанная версия найдена тут […]

  18. Entreprenerd » Track Google AdSense Clicks with Google Analytics Says:

    […] Digital Point’s Shawn has created a piece of JavaScript code that allows you to track your Google AdSense clicks through Google’s Analytics statistics package. The stats that are given will shed more light on what pages your visitors are clicking links to ads on and what pages they are not. Additionally, SEO Book has followed and developed one as well. The advantage of SEO Book’s is that it works both in Internet Explorer and FireFox whereas Shawn’s only works in Internet Explorer. […]

  19. atul Says:

    from where can I get this blog script? Its so simple and yet very attractive.

  20. Shawn Says:

    This is WordPress with a custom template.

  21. » Seguimiento de Adsense en Analytics Says:

    […] Shawn nos propone un pequeño código para que pongamos en nuestro sitio web (al final de todos los bloques de Adsense) mediante el cual se podrá hacer un seguimiento de Adsense dentro de aquellos afortunados que disponen ya de Google Analytics. […]

  22. enrii.blog » Tracking Adsense Clicks with Analytics Says:

    […] Most of you must have been wondering, which page of my site generates the most income? You can now get it answered with a new Adsense Tracking script by Shawn Hogan. Basically, all you have to do is to create a goal in your Google Analytics, then add the script to the bottom of all your pages. However, the script doesn’t track Firefox clicks. Another implementation by Aaron Wall claimed that his script is able to do that. I still don’t have any of them installed in my blog yet as my blog doesn’t generate any revenue. Let me know if any of the scripts works for you. […]

  23. Ivan FXS Says:

    Strange it is:

    elements[i].onfocus = adsense_click;

    - aren’t onfocus and onclick mixed here?

  24. Juan Says:

    I need help. Don’t Work!

  25. J-Foster.NeT » Newest Adsense Tracking Tool Says:

    […] For the ones who are using Google Analytics to track their site traffic, Shawn Hogan just wrote a handy javascript code to track Adsense clicks as well. Visit Shawn’s site to explore how to implement this new handy tool and some examples related. Posted by J. Foster | […]

  26. klmarlon Says:

    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?

  27. ChitikaNews.com » Blog Archive » Track Chitika Ads with Analytics Says:

    […] <script type="text/javascript"> // by Shawn - // http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html // Put this at the bottom of the page (after the last AdSense block) // Update: Randy added Chitika […]

  28. Web Analytics Guide » Blog Archive » Track Chitika E-Minimalls! Says:

    […] Here’s the code: // by Shawn - // http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html // Put this at the bottom of the page (after the last AdSense block) // Update: Randy added Chitika […]

  29. miscblogger Says:

    hey thanks! i will try to use this in both of my blogs!

  30. Stefano Says:

    I wonder if this works..anyone tried it?

  31. Bruk Google Analytics til å tracke Adsense klikk - Søkebloggen Says:

    […] Først lagde lagde Shawn fra DigitalPoint en versjon kalt Click Pepper som bare virket med Internet Explorer (rundt 90% bruker dette fremdeles), men så oppgraderte Aaron Wall fra SEO Book dette scriptet til også å fungere med Mozilla FireFox: http://www.seobook.com/archives/001370.shtml. […]

  32. Brian Says:

    Any chance this could easily be modified for adlinks? I think they use “View ads about” instead of “go to”

  33. The Google Insider » Track AdSense Clicks Through Analytics Says:

    […] your Google Analytics account. Take a look at both and see which one fits your needs the best! +del.icio.us Tags: Analytics, AdSense Posted by JonathanDingman […]

  34. medical info Says:

    I have Analytics and this is very useful. Thanks.

  35. Jafo Says:

    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.

  36. Gregor Says:

    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.

  37. Google Search blog » Google AdSense Analytics Says:

    […] // by Shawn - http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html // Put this at the bottom of the page (after the last AdSense block) function adsense_click() { if(window.status.indexOf(‘go to’) == 0) { urchinTracker (‘/AdSenseClick’); } } var elements; if(document.getElementsByTagName) { elements = document.body.getElementsByTagName(“IFRAME”); } else if (document.body.all) { elements = document.body.all.tags(“IFRAME”); } else { elements = Array(); } for(var i = 0; i < elements.length; i++) { if(elements[i].src.indexOf(‘googlesyndication.com’) > -1) { elements[i].onfocus = adsense_click; } } […]

  38. Pandeblog 2.1 » links for 2006-04-14 Says:

    […] Track AdSense Clicks With Google Analytics (tags: adsense google) […]

  39. Small Business SEO Says:

    Very usefull code Shawn. Been looking for something to help me track adsense clicks. Thanks.

  40. Rahul Says:

    Dear All
    plz tell how to set up a goal for Adsense in Google Analytics

  41. Mike Lipkie Says:

    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?

  42. Make Money with Adsense - Track AdSense Clicks With Google Analytics | Make Money With Adsense Says:

    […] Track AdSense Clicks With Google AnalyticsDigital Point s Shawn has created a piece of JavaScript code that allows you to track your Google AdSense clicks through Google s Analytics statistics package. […]

  43. Zombie Says:

    your script only works with the IE.
    Firefox doesn´t support “window.status” for security reasons.

  44. 100 Top links for Adsense : Top Links : eConsultant Says:

    […] Track AdSense Clicks With Google Analytics [See also : || webmaster || ] […]

  45. Isaac Paton Says:

    It don’t work with firefox

  46. Meethere.org Says:

    Will it work for referrals and search results?

  47. Markus Merz Says:

    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.

  48. Doug Karr Says:

    Just wanted to add my thanks!

  49. Track your AdSense Ad Clicks to further maximise on your returns | Chaos Laboratory Says:

    […] AdSense Tracker script for IE - shows you how to link the clicks to Analytics. Doesn’t work with Firefox. […]

  50. O.Butler Says:

    I am able to track Adsense clicks; however, is there a way to track which page the adsense ad was clicked?

  51. O.Butler Says:

    Never mind…I found a report that tells me which page the adsense ad was clicked.

  52. BJC Says:

    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

  53. Dave Jackson Says:

    This no longer works as Google has disabled the URL code. Hover over any AdSense ad and you’ll see it no longer shows the URL needed for this script to track.

    Kind regards,
    Dave Jackson
    http://monetizethis.blogspot.com/

  54. Ho Feng Wong Says:

    This method doesn’t work anymore? Am I right?

  55. Recovery data Says:

    I try,Seems google changes,click can’t count.

  56. nanoashok Says:

    i pasted the code in bottom of google ads, then what i need to do in next step, what i will do it generate the clicks?

  57. IntelliGenius Says:

    Google still hasn’t added such adsense tracking tool inside the urchin analytics. I hope they do it soon.

  58. Marc Says:

    Thanks, i have found now the modified version also working with firefox and it seems to work perfect

  59. Best tracking tool for adsense - Page 2 - Ad-Sensing.com Says:

    […] don’t know if this still works: Track AdSense Clicks With Google Analytics and i don’t know if it can be similar to conversions __________________ This is my $#!*?!#"&!! blog, please DO NOT click here! […]

  60. Sakib Al Mahmud Says:

    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

  61. kamell Says:

    I cant understand how to track Adsense clicks

    plz any one explain again

  62. wizualizacje Says:

    Thats cool . Thanks fot that.

  63. sugestie sistem de verificare si blocare a click-urilor Says:

    […] Uite aici ceva interesant: [url=http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html]Track AdSense Clicks With Google Analytics[/ur […]

  64. Tacio Almaraz Says:

    I am able to track Adsense clicks; however, is there a way to track which page the adsense ad was clicked? - the same question from me.

  65. Make Money Online Says:

    Hi..
    Do you have a code to track the adsense ad URL/keyword and the page where it is clicked ??

    I have a dynamic site, so tracking is difficult :-(

  66. top2learn Says:

    Thanks Shawn for this great tip.I think Ad Free Stats
    tracking tool will help too.

  67. Debt Cures Says:

    I just tried adding the URL http://pagead2.googlesyndication.com/pagead/ in the goal URL field on the goal set up (using Head Match). Is this going to work for me? It seems like it makes sense.

  68. Money Making and Blogging Tips Says:

    It is a nice code shawn even though adsense and analytics is in integration now. They might have read about this in 2005. Today is 2008 and the code is still helpful. Keep it up.

  69. Proxified Says:

    Although this post is too old but as i am a newbie in programming its pretty useful for me

    Thanks alot

  70. Internet Marketing Says:

    Has anyone found the solution for a all in one tracker for both IE and firefox?

  71. Adleer Says:

    That is great I will use the script in my website

  72. Islam Abou El Ata Says:

    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 !!

  73. Perika Says:

    It will do work in firefox .

  74. Google Bizkit Says:

    Awesome info, and thanks for the php script you provided!

  75. wizualizacje Says:

    Google Analytics is more complex I thoutht. Thanks, I will check it.

  76. tech and gadget updates Says:

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

  77. JBasket.com.au Says:

    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

Leave a Reply