Your Own (Free/Open!) Adserver for Mobile
One of the requests I’ve heard a few times from publishers at AdMob is something of the form of “how can I run my own advertising along with/together with/on top of AdMob?” Usually what the publishers want to do is accept a request to advertise directly from someone looking to do some marketing, but they just don’t have the tools they need to manage the advertising on their site. While we would love to build that stuff right into the mobile publisher tools we offer there are just so many hours in the day. And that set of stuff isn’t high enough on the totem pole to get proper attention yet.
Fortunately, like just about every other problem in the modern world, it can be solved with some open source tools and a bit of elbow grease. I’ve used an open source package called Openads in a few previous projects. Actually I used phpAdsNew and Max Media Manager, two of the projects that went into what is now Openads. It’s a fantastic project, very much under active development. However the things that are “standard” behavior on the web at large are somewhat at conflict with big swaths of the mobile web. For instance, the de-facto ad delivery method relies on browser Javascript support for rewriting the part of a page that the ad will occupy. Something that definitely isn’t yet a common feature on mobile browsers. Not to worry though, Openads supports what you need to get ads into mobile pages if you know where to look. Currently the mechanism I’m going to use only generates code for PHP, so this is only going to be simple if your publishing platform is PHP or can execute PHP for parts of a page.
I used the 2.3 release of Openads while I was playing around. There are a bunch of interesting features in there that make it worth checking out. It’s currently marked as beta though, so just keep that in mind if you decide to run it. The users guide for 2.3 does an excellent job of describing how to install and configure Openads. Their installation configurator is really slick actually. 2.0 had a great installer, this one is even better. All the potential setup issues were stopped in advance and the warning messages came along with the commands to fix them, which worked perfectly. Pretty much all you need is a working PHP install and MySQL.
The first thing you’ll want to check is that you have the option to allow XML-RPC invocation code allowed. You can find the option under “Invocation Settings” on the Main Settings subsection of the Settings tab. That enables the option when creating a publisher zone to have the server generating the page request an ad directly from the adserver instead of generating an HTML/Javascript snippet and relying on the browser to fetch the ad. Once you have that on you can create a zone for your mobile site (see the Openads docs for how to create advertisers and how to create publishers if you aren’t familiar with Openads). Instead of using the default advertising code on the “Invocation Code” tab for the zone, choose the XML-RPC Tag option from the drop down list. Paste that snippet of code into one of the PHP pages where you would like ads to start appearing, and either modify the include_path setting or copy the lib/xmlrpc/php/openads-xmlrpc.inc.php file from the Openads distribution to the same directory as your script. When you load the page, and assuming you have some ads assigned to the zone you created, you’ll see an advertisement on the page now. And more importantly, the ad will still appear when you hit it with a mobile browser!
If you see an error instead of an ad you might need to install the XML-RPC pear package for PHP. For most modern PHP distros that’s just a simple “pear install XML_RPC” from the command line on your server and you should be all set. Other things to keep in mind are that some of the features from Openads won’t work very well for most mobile userbases. Their base banner/text ad limiting, giving an overall limit to the number of times a banner can be displayed or the number of times it can be clicked will be no problem at all. However the session tracking stuff, limiting the maximum number of times any given user can see a banner over a period of time, will only work in a subset of cases. The session tracking is based on the use of cookies, and although the situation with cookies on mobile seems to be getting better, their support is definitely not universal. How “not universal” depends on the carrier networks that your users are on, the gateways they happen to be going through, how new their devices are, and in some cases the security settings they might have enabled.
Of course, at AdMob we like to think that we’re getting pretty good at turning mobile pageviews into money for publishers and clicks for advertisers. There are certainly cases where a particular advertiser is all hot and bothered to get up on your property, but there are also dry times when you have pageviews but nothing to populate them with (at least if your media properties are anything like the ones I’ve been involved with). So the best of both worlds is really to sell your own inventory when you can get a great value for them, but fall back on a more general network when there’s no ad to serve. Fortunately the good folks at Openads have started to build a plugin architecture for Openads, so I was able to write an invocation plugin that returns an ad from the Openads server when available and falls back on AdMob if there’s nothing. In order to install it:
- Download the plugin.
- Unpack the tarred and gzipped file into the root of your Openads install.
- Edit the plugins/invocationTags/admob/admob.plugin.php file and swap in your AdMob site id where it says “INSERT SITE ID”. You can find your site id from the my sites page on AdMob. Click on the site install code link for the site you want to use, and the site_id is up in the URL you’re taken to.
- Now you’ll have an additional “AdMob Tag” option when you generate the invocation code in Openads for any zone. Default behavior is to use Openads first, and request an ad from AdMob if there’s nothing available.
All in all, very nice. There are some things that could be done with Openads to make it a bit more mobile friendly. For instance, I can’t find a way to link a banner zone and a text zone. Openads has the ability to “fallback” between zones, but seems to insist that the two zones being linked are the same size. Makes sense in web layout terms, but on mobile pages tend to frequently be one column, and publishers will insert a banner if they have a banner and fall back to text if they don’t. There isn’t a very easy way to capture that pattern from what I’ve seen. Also, the MMA banner sizes aren’t in the banner drop down by default. You can of course enter them as custom sizes on both the zone and each banner, but that can be a pain. If you want to add them to the dropdown you can add the following to lib/max/resources/res-iab.inc.php under your Openads install:
$phpAds_IAB['MMA X-Large (305 x 64)'] = array (’width’ => 305, ‘height’ => 64);
$phpAds_IAB['MMA Large (215 x 34)'] = array (’width’ => 215, ‘height’ => 34);
$phpAds_IAB['MMA Medium (167 x 30)'] = array (’width’ => 167, ‘height’ => 30);
$phpAds_IAB['MMA Small (112 x 20)'] = array (’width’ => 112, ‘height’ => 20);
And the MMA sizes will appear in the dropdowns for both.

September 21st, 2007 at 1:16 am
This is really great, Mike! Thx. Just one question: will this work both for WML and XHTML MP code or only one of them?
September 21st, 2007 at 7:51 am
It’ll work in both, though the default is to put in a tracking pixel with the ad text which may not work (and display as a broken image indicator) on some handsets. But the difference between XHTML/WML is just one of presentation, which you can setup whatever way you want in the code to render the page.
October 27th, 2007 at 12:26 pm
Mike -
If you have any suggestions on how we can make Openads better for the mobile community, please let us know. The easiest way is to post to our forums (forum.openads.org) or to our developer issue tracker (developer.openads.org). Thanks for these pointers!
Sincerely - Scott Switzer - Openads Community Leader
November 19th, 2007 at 11:44 pm
Mike, can you please point to some tutorial on creating plugins for openads; thanks in advance.
November 19th, 2007 at 11:49 pm
I’m not sure if there is a tutorial, I just dug into the source and got it working. The source is quite clean and well structured, it doesn’t take long at all to get familiar with it.
March 13th, 2008 at 10:53 am
[...] site owners sell their own inventory on top of AdSense very interesting. I was fooling around with a system for mobile publishers to represent their own inventory for mobile on top of existing networks. Looks like others were thinking in the same direction. I wonder how [...]
December 2nd, 2008 at 3:09 pm
9jawap.com uses wml, but i think it runs admob but the images dont show at all. I guess it runs only text ads.