7is7.com > Software > Firefox > Greasemonkey > AdSense Click Protection
Firefox Head

AdSense Accidental Click Protection

Make your Google AdSense ads safe against accidental clicks.



If you use Google AdSense, you will know that it is forbidden to click on your own ads. Unfortunately there is always a risk that you accidentally click on them, and the risk isn't limited to you clicking, anyone using the same IP number as you (such as your family members or office co-workers) could be clicking on them, especially as they may not be as careful as you are (or they may not even be aware of it). Google has no way of knowing who is doing the clicking and will assume that any click from your IP number is probably from you and decide to ban you from AdSense.

To prevent such a scenario I had for a long time been using a Greasemonkey userscript called "AdSense Prevent Accidental Clicks" that blocked clicks on your own AdSense ads. I installed this for every user on every computer in our house.

This worked well until Google bought Doubleclick and migrated AdSense to another server on doubleclick.net. This change unfortunately caused the userscript to stop working. It may seem like a trivial change to update the URL of the AdSense server in the userscript and get the script to work again, but there were some other usability issues with the userscript which had always bugged me: You had to enter your AdSense ID manually, and if you accidentally did it wrong (or entered a blank number by canceling) it was difficult to correct your mistake. Another issue was that your clicks were completely blocked, while sometimes one does actually want to visit the advertised site (but then without causing an actual AdSense click). Prompted by the fact that the script was no longer working and given these issues I decided to write a completely new userscript, which you can find below.

The Script and Installation

To use AdSense Click Protection, you must be running Firefox with the Greasemonkey (review) extension. If you are properly set up follow these steps:

  1. Install AdSense Click Protection (by clicking on this link).
  2. Go to one of your own pages that contains your own AdSense ads, the script will ask you to confirm that it's your AdSense ID. Confirm it and your AdSense ads will be protected.

The AdSense Click Protection script has the following characteristics:


There are three ways to verify that the script is working:

  1. The "Ads by Google" link is not clickable.
  2. Hover over one of the actual ad titles and look at the URL that is shown for it in the status bar. Does it look like the URL of the advertiser or does it look like a link to the "googleads" server? If the link is directly to the advertiser the script is working and has stripped the URL of AdSense coding.
  3. Visually the most obvious change is the fact that the links in the ad block that have been stripped of AdSense referral coding have a light green background and a dark green dotted border around them. Additionally those links are not underlined.
Sample Protected Ads (Screenshot):
Sample protected AdSense ads

The AdSense Click Protection script blocks click events within Google's AdSense code and replaces it with a clean redirect to the advertiser's URL. This should (we hope) make it safe to click on those links. As a result the other parts of the ad block are not clickable at all.

Changing AdSense ID

If you have accidentally set up protection for the wrong AdSense ID, right-click on an AdSense adblock and choose This Frame > show only this frame. Then go to the Greasemonkey menu by right-clicking on the Greasemonkey icon in the status bar. Under User Script Command you will see two options: Set AdSense ID and Clear AdSense ID. Set AdSense ID will protect the AdSense ID associated with the current AdSense ad block.

AdSense Click Protection Menu:
AdSense Click Protection Menu


The prohibition to click on your own ads has probably prevented a lot of people from clicking on interesting ads they saw on their own site (I know it has for me). The AdSense Click Protection userscript could therefor make a whole demographic of active webmasters available for these ads. This may turn out to be an advantage for AdWord advertisers on AdSense, as it may actually increase the number of click throughs on their ads without costing them anything extra.

Use at your own risk!

I can't stress this enough, I can practically predict that some people are going to accidentally get banned from AdSense by failing to use this userscript properly! So please, please, please be careful. Remember Greasemonkey must be turned on (it's easy to turn off and forget), you must have entered the correct AdSense ID to protect your ads. Try hovering over an ad before clicking on it to see if it looks ok. If you don't see the ad links with a green background and dark green dotted border then something is surely wrong. Also realize that Google could use other techniques to intercept clicks on Ads, making your clicks count even when stripped of their AdSense referral encoding. The script tries to intercept these clicks itself, but you never know. There is also the risk that the server serving AdSense ads will change again in the future causing this userscript to no longer work. If you are unaware of such a change you may end up clicking on your own ads in the false belief that this userscript is protecting you. Also in this case if you do not see the green background and dark green dotted border around the ad titles you should know something is wrong. Besides these risks there are probably more risks that neither you nor I are aware of.

So remember, by using this script and blindly trusting it to work you might be placing your AdSense account at risk. It's a risk that you choose to take. If you don't want to take this risk, just don't use it or don't click on your ads anyway (and use this script only as a layer of protection against accidental clicks).


Get Firefox! Download LibreOffice Use Fedora