Forum Moderators: martinibuster
Concept: The following uses onMouseOver and onMouseOut to change the background colour of a div containing an Adsense banner (the background colour change is not visible to a user). onbeforeunload code checks if the background colour of div with id "google_ad_1" is set to "#000000" and if it is, fires a new image to log the click.
In page header
<script type="text/JavaScript"> function log_click() { if (document.getElementById("google_ad_1").bgColor == "#000000") {(new Image(5,5)).src = "google_track_script.cgi?adclicked=1";} } window.onbeforeunload = log_click; </script> In page body
<div style="width:[width of adsense ad]px" id="google_ad_1" onMouseOver="this.bgColor='#000000';" onMouseOut="this.bgColor='#FFFFFF';"> <SCRIPT language="JavaScript" SRC="http://www.not-same-domain.com/mock_adsense_ad.js"></SCRIPT> </div> In Firefox the only way I could get a click to be logged in Firefox was to insert an alert("foobar"); at the end of function log_click (not viable) or replacing:
(new Image(5,5)).src = "google_track_script.cgi?adclicked=1"; with
document.write('<img src="google_track_script.cgi?adclicked=1" width=5 height=5>'); which effectively redraws the page your on, loading the image, before going to the clicked URL. Causes a dupe log if a user hits the back button after clicking though. Also not sure if this would violate TOS.
Also not sure if this would violate TOS
I would be extremely surprised if you can get away with it, my money is on an ear pinch or worse a TOS violation account ban.
change the background colour of a div containing an Adsense banner
It sounds to me like the Firefox portion would be in violation of the TOS. If the IE portion doesn't visibly affect the appearance during a mouseover or the behaviour following a click, IMO it would probably be OK. You'd want to back-test it with a variety of browsers and versions, especially IE6.