Forum Moderators: martinibuster

Message Too Old, No Replies

Any One know why click trackers for adsense don't work with FireFox

         

neiq

4:26 am on Mar 21, 2005 (gmt 0)

10+ Year Member



Hello all,
Any One know why click trackers for adsense don't work with FireFox.

jomaxx

5:05 am on Mar 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't shed any light on why, but I seem to remember from when I first implemented the script a year or so ago that it also did not record clicks from Netscape (which is the same basic implementation as Firefox).

JamesR3

6:23 am on Mar 21, 2005 (gmt 0)

10+ Year Member



The technical explanation is probably that Firefox/Netscape have a different document object model than IE. The click trackers that I have seen capture a variety of events, such as ONFOCUS, ONMOUSEOVER, ONSUBMIT, etc. To do this, they need to know what all those events are called in the browser, and how to refer to the browser's various objects to ask for the events associated with that object. I'm no expert on this but I would assume that either some of the needed functions are not present in Firefox/Netscape, or that they have a different naming scheme (so that they perhaps COULD be coded for, but as yet people have only bothered to make scripts for IE since it is far more prevalent).

martingale

4:25 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



That's the case with my click tracker.. it uses onfocus on an iframe, and firefox doesn't support that. If anyone has a solution that captures firefox clicks too I'd like to hear about it.

JamesR3

5:07 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



I can't believe that there aren't a dozen javascript experts that read this forum. Can someone definitively answer this question, and maybe post some code? If not, I'll play around with it for a bit, but this isn't my forte.

martingale

6:29 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



I did definitively answer the question. The click tracker adds an "onfocus" handler to the AdSense iframe. Firefox doesn't support the onfocus handler on iframe's, but IE does. So the click trackers work with IE, but they don't work with firefox, because firefox ignores the onfocus. Firefox's behavior is not "incorrect". The standard does not specify that an iframe must support onfocus. Firefox chooses not to support it.

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

JamesR3

7:02 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



thanks for the info martingale. I guess we should have searched more before asking -- the info is already here in the forums. And, I didn't read this thread closely enough to really understand the code, but it looks like people have code that works for firefox: [webmasterworld.com...]