How to format your WordPress blog for Google Adsense Mobile
With the recent announcement that Google Adsense may now be included on mobile versions of websites, bloggers should now make sure that their blogs are optimized or formatted for browsers on mobile devices. The mobile users market is expanding and as a blogger who wants to monetize your content and tap into this market, this is the way to go.
In these easy steps, BloggingProfits shows you how to format your blog for mobile browsers and show Google Adsense for Mobile:
1. Preview your existing blog’s theme on a mobile browser such as Opera Mini. This assumes you have a mobile device. Point your mobile browser to operamini.com, then click on “Download Opera Mini.”
If you don’t have a cellphone or mobile device, don’t panic. There is an online simulation or demo of the Opera Mini browser. Use the simulation as if you’re browsing from a cellphone.
The Mini Opera Simulator

2. Paste the Google Adsense for Mobile to your theme’s templates. Because AdSense for Mobile requires server-side scripting — unlike the client-side scripting in JavaScript which is not supported by most mobile browsers or webpages — the code is different from the ordinary Google Adsense code. You are given the choice of;
- PHP v4.3.0 or greater
- CGI/Perl v5.8 or greater
- JSP v1.2 or greater
- ASP v3.0 or greater
Since WordPress runs on PHP, we will get the PHP version of the Google Adsense for Mobile code which looks like this:
<?php
$GLOBALS['google']['ad_type']=’text’;
$GLOBALS['google']['channel']=’CHANNER ID HERE’;
$GLOBALS['google']['client']=’pub-PUBLISHER ID HERE’;
$GLOBALS['google']['format']=’mobile_single’;
$GLOBALS['google']['https']=$_SERVER['HTTPS'];
$GLOBALS['google']['host']=$_SERVER['HTTP_HOST'];
$GLOBALS['google']['ip']=$_SERVER['REMOTE_ADDR'];
$GLOBALS['google']['markup']=’xhtml’;
$GLOBALS['google']['output']=’xhtml’;
$GLOBALS['google']['ref']=$_SERVER['HTTP_REFERER'];
$GLOBALS['google']['url']=$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$GLOBALS['google']['useragent']=$_SERVER['HTTP_USER_AGENT'];
require(‘http://pagead2.googlesyndication.com/pagead/show_ads.php’);
?>
3. Preview your blog again on a mobile browser or the Opera Mini Simulator. You should see the Google Adsense for Mobile (Adsense Help says it will take 48 hours to see the mobile ads, but the ads showed on Blogging Profits mobile a few minutes after adding the code to the template.)
We added the Adsense for Mobile code on our single.php template, just below the author and date tags. Shown below is a screenshot of the mobile version of BloggingProfits, showing the previous blog post (Google Adsense for Mobile is now here) with the Google Adsense for Mobile.

* An interesting observation: Mobile ads are also showing on the desktop version of the blog, because the code is added to the template.
One Response to “How to format your WordPress blog for Google Adsense Mobile”
Rohit on January 25, 2011
hmmmmmm Its working….. thanks