Well it looks like Google Adsense for Mobile is counting web crawlers as Page Impression. So right now my stats are are bad, and have even worse Page CTR.
My site uses Drupal, and with the help of the browscap module, I currently use the following code.
A quote from the browscap README.txt
Modules wishing to make use of browscap data may call browscap_get_browser() anywhere they would otherwise call get_browser() (see function.get-browser). Note that browser_name_regex is not returned - otherwise, the results should be identical to calling get_browser().
So here is the code I use, as I will show the Ads for the Google Bot (even though I currently have a problem with Google is indexing their Mobile Adsense Advertisements )
I know what the Google Bot looks like :
Nokia6820/2.0 (4.83) Profile/MIDP-1.0 Configuration/CLDC-1.0So I just check the HTTP_USER_AGENT for Google
(compatible; Mediapartners-Google/2.1; +http://www.google.com/bot.html)
BEGIN CODE
<?php
/* *************************************************************** */
/* Check for browser */
/* *************************************************************** */
$display_ads = true;
// Will show Ads for Google
if (! ( stristr($_SERVER['HTTP_USER_AGENT'],"google") ) ){
// browscap_get_browser is a Drupal Module function
$browser = browscap_get_browser(null, true);
if (array_key_exists("crawler", $browser) && $browser['crawler']==1){
// found out its a crawler, so set the Display Ads to false
$display_ads = false;
}
}
/* *************************************************************** */
/* GOOGLE AD CODE */
/* *************************************************************** */
if($display_ads){
$GLOBALS['google']['ad_type']='text';
// ...
@require('http://pagead2.googlesyndication.com/pagead/show_ads.php');
}
?>
END CODE
You may of noticed I placed the @ symbol (also known as the error suppression operator) in front of the require function. As I have seen the request fail, and this tells the function to fail silently. The page will continue to load, but just wont have any Ads. Also would be a good idea to set in the php.ini to have display_errors = Off
Also with Drupal you don't want users to see the errors so :
Administer > Site configuration > Error reporting
Where you have : "Error reporting:"
Set this to "Write error to the log"
I hope this helps those who have just started with Mobile Adsense, and are getting very high Page Impressions due to web bots / crawlers
No comments:
Post a Comment