Jim Westergren
A blog about me, my projects, SEO, Web Development and Personal Development.
"If we did all the things we are capable of, we would literally astound ourselves." - Thomas A. Edison

Protect yourself from invalid Adsense clicks

Note: Take a look at my project, I offer you a professional website for free with N.nu.

Have you also heard of those horror stories of Google banning Adsense accounts for the smallest mistakes?

You have read the Terms and Conditions and you know the basics but what do you do when you show your friend your site on your computer and the first thing he does is to click the Adsense ad on your site? (actual example). Well you email Google Adsense and explain what happened, it will usually be no problem.

I recently made a WordPress CMS with Adsense and I have one staff working on it as well as other people, adding text and so on on many domains. The risk to click by mistake is very big …

So I made this script

Add this at the top with all the IPs you have used to login to your Adsense account:

<?php
$ip = $_SERVER["REMOTE_ADDR"];
$ip_array = array("xxx.xxx.xxx.xx", "xxx.xxx.xxx.xx", "xxx.xxx.xxx.xx", "xxx.xxx.xxx.xx", "xxx.xxx.xxx.xx");
?>

Then on all the Adsense codes replace with the following:

<?php
if (in_array($ip, $ip_array)) {
echo 'Blocked Adsense';
}
else {
echo '<Here comes the adsense code>';
}
?>

That will display “Blocked Adsense” instead of Adsense on those computers with the same IPs you used to login to your Adsense account and you don’t need to worry. On my CMS I made it to display non-clickable images of Adsense instead that looks just like Adsense so it doesn’t look weird when my staff and writers looks at the sites.

If all else fails, check out the AdSense Reinstatement Guide.

Boomark This! Subscribe to the RSS feed
About the Author Jim Westergren Jim Westergren is a web entrepreneur from Sweden who lives together with his wife and son. Some of his interests are programming, web development, SEO, writing and taking photos. His current major project is N.nu. Read his .
Follow Jim on Twitter or subscribe to this blog. In Swedish: presentation, blog.
32 responses »Leave a comment
  1. Brian Pratt
    said on February 14, 2007 at 00:21

    Hi Jim

    Nice tip thanks.

    Another option is to install an adserving script like openads (http://www.openads.org/).

    There is a GEOIP file available which will allow you to not show ads to particular countries or even cities.

    Some hosts have this script as part of their fanastico build.

    You then just serve adsense with the script & all is taken care of.

    It also has other options like only showing an ad to a user once every 30 seconds or only showing an ad max 3 times to a visitor in one day etc.

    Hope this helps
    Regards
    Brian

  2. Jim Westergren
    said on February 14, 2007 at 13:28

    Thanks Brian, that could be useful for more advanced uses.

    Another use is to not serve ads to those coming from social network siteso to increase the vote percantage.

  3. Maki
    said on February 16, 2007 at 00:07

    Thanks for the great tip. Was previously using the greasemonkey script for preventing accidental clicks but this works just as well.

  4. Thermage
    said on February 18, 2007 at 17:57

    A very interesting site, I think. The Idea of Technology was new for me but worth to be read and thought abot it (although I’m not a native english-speaker and have some difficulties whith this language)

  5. eli
    said on February 19, 2007 at 12:41

    simple but very useful tips. thanks

  6. Australia immigration
    said on March 26, 2007 at 08:55

    your method can only apply to the lease line or fix IP address, for those who is not using fixed IP address to go online, It may be useless. I found using adlogger will be an better solution because it can block the range of the IP address for example 60.xxx.xxx .

    what do you think ? :)

  7. Michael
    said on March 26, 2007 at 11:42

    You could also install adlogger. There you can also add ips to a list so that ads are not shown for people who visit your website with these ips.

  8. Strafverteidiger Freiburg
    said on May 2, 2007 at 13:58

    Very great info. i will protedt us now as well.

  9. my conversations with adsense team
    said on June 5, 2007 at 11:16

    well I don’t think we need to be as much careful about accidental clicks.The adsense team knows that this could happen.I have myself consulted adsense for this purpose.You can see my full conversation with the adsense support team.

  10. Dog
    said on June 28, 2007 at 22:48

    It is very helpful tip!

    Thank you very much!

  11. ODLS
    said on October 24, 2007 at 18:36

    One of the biggest worries for webmasters if you get banned for something that was really unintentional. Thanks for the tip.

  12. Aelizia
    said on November 5, 2007 at 11:11

    Hi,
    Its a useful tip.Actually i am looking information regarding Adsense click and i am glad i found your blog.I am going to use this Adsense script right now. Thanks for the valuable information.

  13. youtube
    said on December 14, 2007 at 08:57

    Thanks Brian, that could be useful for more advanced uses.

    Another use is to not serve ads to those coming from social network siteso to increase the vote percantage.

  14. Bob Mill
    said on December 19, 2007 at 20:55

    This is very useful script! I will post it on my website – check it out at http://www.ad-sensing.com

  15. Google Horror Stories
    said on March 21, 2008 at 16:02

    That is a nice tip.. But what would be even better is if google would just ignore clicks generated by the adsense publisher.. And ignore clicks from obvious click bomb attacks.. Google is supposed to be a tech leader and they cannot do this? All they can do is ban adsense publishers for simple mistakes like accidentally clicking on their own ad. Give me a break..

  16. Don
    said on April 1, 2008 at 04:29

    Hi Jim,

    Cool idea! If someone wanted to take it a step further and actually block ad views and even page views by using cookies and IP tracking they could get a script like AdSenseClickLock from http://www.AdsenseClickLock.com.

    The script is very easy to install and can help prevent invalid clicks and potentially save an account from getting banned.

    Thanks,

    Don

  17. Ealtamira
    said on June 4, 2008 at 10:00

    Nice trick, but I don’t think adsense was so evil

  18. Patrick
    said on July 26, 2008 at 23:40

    Personally, I prefer to use Firefox with the Adblock Plus plugin. The big advantage is, that I do not use to put the two class B subnets of my provider in that array ;) and can easily check, if ads and content match.

  19. Eunus hosen
    said on July 4, 2009 at 10:23

    Thanks. If i have 3 ad unit in a page what can i do? How I install this code?

  20. irfan
    said on March 6, 2010 at 11:33

    ya i think adsense click locker is the best solution against click bombing,but unfortunately its not free

  21. 2FUN BD
    said on March 27, 2010 at 19:53

    Its a nice Info. Thank you For share this.

  22. Man health
    said on May 22, 2010 at 09:07

    I think disable java script will be enough

  23. Faceeee
    said on August 30, 2010 at 05:56

    Does google allow this coding?

  24. PhilTalks
    said on December 29, 2010 at 13:49

    do you have a script which will limit the clicks? so that users cannot make multiple clicks on your ads. Thanks :D

  25. Ana
    said on June 4, 2011 at 17:23

    Thanks Jim. I will try this one after i got banned from google adsense because someone clicked more than 100 times on the add.

    Ana is wellbeing writer

  26. oxi
    said on June 25, 2011 at 00:35

    Hi, interesting piece of code!

    I’m currently looking into ways to effectively prevent click-bombing, BEFORE I go into the AdSense venture!

    I would like to limit showing Ad units, to let’s say 1 click per IP per day, then use javascript to hide the Ads after first click, along with PHP to hide them for 1 day for that IP.

    ***I just have this concern since I have no experience with Adsense at all: What if a click-bomber copies a link in your Ads -which as far as I understand it contains all your referer info, etc- prior to actually clicking it, then paste and open this link subsequently and repeatedly in his browser address bar? Wouldn’t this be just like clicking on your ads? So then it wouldn’t matter whether you hid them or not!!***

    I’m willing to believe that Google uses some kind of unique-click hash code generator to prevent the aforementioned. But could someone confirm this to me, please? Much, much, much appreciated!

    For obvious reasons, just in case they don’t have this kind of unique click hash code, I don’t want to post this question in Google forums. Although, that would be the place to ask, really.

    Hope someone can illuminate me!

    Regards,
    oxi

  27. surinder
    said on November 4, 2011 at 11:54

    if you need to know how to create google adsense account easily , come to my blog http://www.ikonwebdesigns.com/blog

Leave a Comment

To quote: <blockquote>text to quote</blockquote>

You can use these tags: <a href=""> <blockquote> <code> <em> <strong>


To have a photo of you beside your comments, upload a photo here.

Pingbacks
  1. [...] But wouldn’t be nice if you weren’t clickbombed in the first place?  Thats where code such as this by Jim Westergren comes into handy.  This code will limit multiple clicks by IP and shut down your click bomber before he gets a chance.  The problem is that this can shut down legitimate clicks.  Do you have code that you use to protect your Google Adsense account, feel free to share! [...]

    Pingback by Protect your Adsense account from Invalid clicks — December 19, 2007 @ 19:49

  2. [...] For more info see the source [...]

    Pingback by Top of Review ’s » Protection from invalid Adsense clicks — February 12, 2008 @ 04:05

  3. [...] your ads, it will automatically display another advertisement instead. For more details, click here. Please let us know if you know anymore valid JavaScript we can use to prevent invalid [...]

    Pingback by Protect Your AdSense Account from Click Bombing Invalid Clicks | Webmaster Crunch — August 2, 2010 @ 20:17

  4. [...] There is a script I found on a website to protect Adsense invalid clicks so, Use it if you can. The script is available here [...]

    Pingback by [How-To] Protect Your Blog From Adsense Invalid Clicks | TechInfo Blog — January 21, 2011 @ 17:52

  5. [...] There is a script I found on a website to protect Adsense invalid clicks so, Use it if you can. The script is available here [...]

    Pingback by [How-To] Protect Your Blog From Adsense Invalid Clicks « Plugins « Wordpress « Baguzajja[dot]Info Personal Site Blog — January 31, 2012 @ 16:54

Previous post in category:

Next post in category:

Design by myself:  valid XHTML and valid CSS.