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

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 { ?>

Here comes the adsense code

<?php } ?>

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.

13 Feb 2007

Comments powered by Disqus
About the Author Jim Westergren Jim Westergren is a web entrepreneur from Sweden now living in Bolivia. He is happily married and has two lovely children. Some of his interests are web development, SEO and writing. He is the Founder and CEO of TodaysWeb offering SEO, web development and manages projects such as N.nu. Read his . Follow Jim on Twitter.

Design, text and custom cache solution by myself.