• Home
  • About

szehau's weblog

Life, Internet, Software, Gadgets, Programming and Investments

  • life log
  • internet
  • programming
  • software
  • working holiday
  • gadget
  • project

Avoid additional Adsense impression from publisher

July 17, 2005 20:12 by Sze Hau 1 Comment

It is always a problem for Adsense publishers that always visit their own websites for testing purpose – Google Adsense will report additional Ad impression. The statistic at Google Adsense’s report becomes inaccurate and might affect the overall earning especially when publisher does a lot of testing on his/her own sites. When impression is increased, page CTR (click through rate) will be decreased and as well as eCPM (effective cost per 1000 impression).

Here is the trick to solve the problem:

  1. Create a page (e.g. adsenseCookie.php) that create a cookie where its expiration date is set to a specific date (e.g. 1 day, 1 month or 1 year from now)
  2. In your page’s source code, check whether the cookie is set. If it is, display an image that is same size with the Adsense’s Ad (e.g. 300×250 pixels). If the cookie is not set, display the Adsense code.
  3. When you want to do a testing on your site, simply execute the page adsenseCookie.php once. Then, your website will show you an static image instead of Adsense (Set the cookie’s expiration date to a longer one so that no need to execute adsenseCookie.php every time you want to do testing on your site).
  4. .

Here is an example code for PHP (adsense size 300×250):

Set cookie page


<?php setcookie('TestCookie', 'ForAdsense', time () + 365 * 24 * 3600 ); ?>

Display Adsense code or Image


<?php
if (isset($_COOKIE['TestCookie']) &&
  $_COOKIE['TestCookie'] == 'ForAdsense') {
?>
<img src="adsenseImage300x250.gif" width="300" height="250" />
<?php
} else {
?>
<script type="text/javascript"><!--
google_ad_client = "pub-XXXXXXXXXXXXXXXX";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php
}
?>

More from my site

  • Received My Free Ubuntu 9.04 Server Edition CDReceived My Free Ubuntu 9.04 Server Edition CD
  • Get banned by PPSGet banned by PPS
  • Working at RakaiaWorking at Rakaia
  • PC Fair 2006PC Fair 2006
  • Employed again…Employed again…
  • I see a cat (which know to translate)I see a cat (which know to translate)

Filed Under: programming

About Sze Hau

Geek. Love programming. Coffee addicted. Married with a child. Working towards financial freedom.

Comments

  1. EngLee says

    July 18, 2005 10:53 at 10:53 am

    Good post! But too bad, I’m using blogger.

    Reply

Leave a Reply to EngLee Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Email News Letter

Sign up to receive updates daily and to hear what's going on with us

  • Facebook
  • Google+
  • Instagram
  • Twitter

More Posts

5 Essential Things You Need To Have At Your Home During The COVID-19 Pandemic

June 1, 2021 22:15 By Sze Hau Leave a Comment

LED Downlight

Troubleshooting A Flickering LED Downlight

February 13, 2016 00:29 By Sze Hau Leave a Comment

Repair A Broken iPhone Lightning Cable

January 30, 2016 00:54 By Sze Hau Leave a Comment

Sponsored Links

Blog Network

  • Personal Fincance Personal Finance – Personal Money Tips, Stock Investment, Small Business and Make Money Online
  • Snippet IT Information technology news, ideas and experiences and opinions

szehau’s weblog

szehau is a software programmer that has strong interest in the world of programming and Internet. He is graduated in University of Malaya, Malaysia with a Bachelor’s degree in Software Engineering. He draws on his passsion for web programming to share with others how to build a successful websites.

Recent

  • 5 Essential Things You Need To Have At Your Home During The COVID-19 Pandemic
  • Troubleshooting A Flickering LED Downlight
  • Repair A Broken iPhone Lightning Cable
  • New Gadget – MacBook Pro with Retina Display (2015)
  • One Watt LED Night Light

Search

Tags

adsense advertisement baby blog blogtal Canon EOS 400D Chinese New Year Christchurch CNY DiGi electronic Facebook FBM Flickr Flickr Uploadr Google Google Maps Google Search Results Google Webmaster Central H1N1 income tax investment joke KLCI KLSE Lake Tekapo Maxis Maybank2u Motueka movie mutual funds New Zealand PC Fair 2009 Queenstown restaurant for dinner sharing stock trackback travel Twitter unit trust visa wordpress wordpress plugin working holiday

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in