How to disable AdSense adverts on your website
Problem
Anyone that runs AdSense knows that YOU MUST NEVER CLICK ON YOUR OWN ADS. Now there’s a very slim chance you might one day accidentally click on an ad, which – if they are in a bad mood – might cause Google to suspend your account, or even remove it.
Solution
This is where the ‘google_adtest’ variable comes in handy. If you add this PHP code to your AdSense block…
<?php
if ($_SERVER["REMOTE_ADDR"]==”XXX.XXX.XXX.XXX”) {
echo “google_adtest=’on’;\n”;
}
?>
…just above the ‘google_ad_client’ variable, substituting ‘XXX.XXX.XXX.XXX’ for your home/workplace IP address, whenever you view pages with these ads on, they will be in test mode. If you click on them, they don’t register, and the advertiser doesn’t get charged. Blow is a full AdSense block example:
<script type=”text/javascript”><!–
<?php
if ($_SERVER["REMOTE_ADDR"]==”111.222.333.444″) {
echo “google_adtest=’on’;\n”;
}
?>
google_ad_client = “pub-#############”;
google_ad_slot = “##########”;
google_ad_width = ###;
google_ad_height = ###; //–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
If you have no idea what your IP address is, try: http://whatsmyip.org/
Please note: This method won’t work if you’re site doesn’t run PHP (obviously, but it could be done with ASP or any other scripting techs) and won’t work if you don’t have a fixed IP.








Add to My Yahoo!
Leave your response!