• 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

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

About Sze Hau

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

Email News Letter

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

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

LED Downlight

Troubleshooting A Flickering LED Downlight

February 13, 2016 00:29 By Sze Hau

Repair A Broken iPhone Lightning Cable

January 30, 2016 00:54 By Sze Hau

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

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

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