Forum Moderators: martinibuster
Here is my click tracker:
<!-- adsense tracker -->
<script language="JavaScript" type="Text/Javascript"><!--
function asLog() {
if (window.status.indexOf('go to') == 0)
{
bug = new Image();
bug.src = '/tracker/as_tracker.gif?ref=' + document.referrer + '&loc=' + document.location + '&url=' + window.status.substring(5);
}
}
var elements;
elements = document.getElementsByTagName("iframe");
for (var i = 0; i < elements.length; i++) {
if(elements[i].src.indexOf('googlesyndication.com') > -1)
{
elements[i].onfocus = asLog;
}
}
// --></script>
This results in the click being logged to my weblog as a hit on "as_tracker.gif" when an IE user clicks on an AdSense ad. I have other scripts that post-process the weblog to compile the statistics by analyzing hits on this image. Note how it works: It iterates the object model and adds the "onfocus" to the iframe that Google creates. You can't do anything to manually edit the Google iframe since that would violate the TOS (must paste in Google's script verbatim.) Firefox doesn't support onfocus.
If you have some other way to do this I'd like to know. ASA has said before that scripts like this do not violate the TOS since they do not modify the AdSense code. There are lots of solutions if you want to modify the AdSense code, but that will get you banned from AdSense... so, for now, no luck tracking Firefox.
Also note this script isn't going to properly track AdLinks hits, as those actually go to another web page that is beyond your control... a new wrinkle. You could at least detect that someone clicked to the AdLinks page I guess (probably the above doesn't work for that.)