buy viagra
Home » AdSense

How to disable AdSense adverts on your website

6 December 2008 No Comment

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.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.