Adsenselogger and Google's TOS

I have been participating in Google's AdSense program for almost two and half months now, and have earned peanuts for placing AdWords contextual ads on two of my other blogsites, i.e. I am only almost there for my first greenback cheque sent by our beloved guys in the almighty G.

Well, I guess I am only doing it just to cover my costs. I have got a nice developer job during day time, and thinking working over-over time in a competitive world for almost 365 days a week like these guys are just insane. However, I always felt fascinated by all these techniques on search engine optimisation, and in the case of Google AdSense, the "AdSense-optimisation". It turns out having a sophisticated reporting tool is important, so you can know exactly how ads have been shown, and which ones have been clicked on. All the details can then be feed back into optimisation, helping the webmasters to build their next golden goose.

However, AdSense's reporting tool might be nicely characterised as "simple", or cruelly described as "lacking". You have your daily total of impressions, number of clicks, and how much have you made -- and that's it. You can set up "channels" to aid tracking, but I personally find it very awkward to use.

Then there are third party "logging" and "reporting" tools that let you track impressions and clicks in real time. Do a Google search on "AdSense tracking", you'll find the net is populated with these tools. There are some free (in beer) and open source efforts, and the most popular amongst them is currently the Adsenselogger.

How does it work?

Since Adsenselogger has been GPL'ed, it is not difficult to look at the mechanics. It requires you to add an almost-2kb Javascript snippet at the end of your document, before </body>, and it does two things when a visitor viewed your site with a Javascript capable browser.

  1. It loops through all IFRAME's on the page, looking for ones that point to Google's ad servers, and then reports the impressions to a server-side PHP script.
  2. When a click has been made, the script will then report which ad has been clicked, and try to figure out the target URL of the ad.

It does the reporting by creating a dummy image object and then assign it with the crafted URL. After the server-side script has collected enough impressions and clicks, you can then use some of the pre-designed reports to work out how you should optimise your AdSense site.

Adsenselogger Issues

The only reference I have is Adsenselogger 1.1 posted on their website. I know their developers are working on 2.0, but I can only evaluate according to what I can get my hands on.

There are quite a few issues that make it less and ideal tool to track your AdSense traffics.

  1. Click-capture code only works for Internet Explorer. It uses only onfocus event on the IFRAME window instance to track whether an ad was about to be clicked, which does not work with about anything but IE. On Mozilla/Firefox, you really need to attach the onfocus event onto the contentWindow instance, i.e. the window container object of the document inside the IFRAME. However due to Mozilla's security model a script cannot window/document objects from a different server.

    I did manage to build a prototype to capture the click event by using a combination of onmouseover, onmouseout and onunload events, and that works with both Firefox and Opera. Again it is tricky with Opera, as its onmouseout event is not that reliable on a IFRAME window, so my solution needs to make an educated guess on whether a click has been generated or not.

  2. Adsenselogger only can track one ad unit on each page. AdSense TOS allows you to have three ad units + 1 adlinks on each individual page, and its impression/click code does not take multiple ad units into account.

    Again, it can be easily fixed by taking individual ad units into consideration, before packaging the impression logs to be sent back to the logger.

I have since been writing my own AdSense tracking script that work on at least IE, Firefox and Opera -- to track my pathetic AdSense earning records. My plan is to write an architecture that is generic enough to adopt to other ad networks as well, just in case 6 months down the track I need to re-code for YPN or MSN ads tracker. Since I have got my inspiration from GPL'ed Adsenselogger, I shall release it as open source when the code is stablised.

Against Google's TOS?

Because those AdSense trackers relies on binding extra event handlers onto objects created by Google's own scripts, I was wondering whether it is against Google's terms of services. From Google AdSense's Program Policies, it says:

Code Modification

Any AdSense ad code or search box code must be pasted directly into Web pages without modification. AdSense participants are not allowed to alter any portion of the ad code or change the layout, behavior, targeting, or delivery of ads for any reason.

Does attaching extra events to trap clicks count towards changing the behaviour or delivery of the ads? I searched the web on Adsenselogger Google TOS, and most results are saying that there is no issue what so ever. Basically mos people reckon you can continue using those loggers without infringing AdSense's TOS.

However, I think I shall just send the AdSense team an email just to be sure. I worded it this way:

... I looked at the code (of Adsenselogger) to see how it tracks clicks, and noted that it uses Javascript to add an event handler on AdSense's IFRAME object. Does that violate AdSense's Program Policies?

I guess the real question is, can I use AdSenselogger without getting banned from the AdSense program?

Or, is there a clear guide on what I can or cannot do with the DOM objects created by Google AdSense?

Two days later I received a reply from Allen of the Google AdSense Team:

We understand that you would like to have more detailed reporting regarding your AdSense account. However, we do not endorse or encourage the use of any third-party tools for this purpose...

...Please note that AdSense participants are solely responsible for verifying that any tools or software used in conjunction with AdSense do not violate the AdSense Terms and Conditions.

Aarrgh! I don't like vague answers -- I want Yes or No! However, it did sound a bit contradicting with other sources, where nearly everyone claims no issue with Google's TOS. So who is right? Or is it a canned message? Google might just be too sick verifying every piece of software whether they are okay or not -- Google wants to reserve the right to boot someone off at will.

Anyway. If you are using a third party AdSense tracking software, make sure you know how it works and be very careful not violating Google's TOS.