Experiment with Mobile Adsense

I’ve been a Google Adsense user for a very long time, and while I won’t be retiring off my earnings any time soon, it helps pay the hosting bill and covers my fancy beer/comic book addiction well. Before MAX I decided to take a look at Adsense for Mobile. Specifically I wanted to use it with an HTML-based application made with PhoneGap. I’ve seen a few applications making use of it (or other ad networks), and I was curious how easy it would be to use. Here’s my experiences with it. I’d love to hear from others using it, or other ad networks, especially in terms of how easy it was to add to your application and how well the reporting works.

Before working with Adsense for Mobile, you have to actually have an Adsense account. I figured that’s assume but it doesn’t hurt to ask. You do not have to have any other account though. So for example, you don’t have to have an Android or iOS developer account. Once logged into your Adsense account, go into “My Ads”, and make note of the ‘More Products’ section on the left.

I had mobile here originally, and clicking on it was a two step process to enable mobile. I believe it simply asked me if I wanted to try AdMob as well, but I just ignored that. Once enabled, you get a “Mobile content” section under your ads:

These options mirror the same choices you get for regular desktop ads. Since I only had one ad to create, I didn’t bother with custom channels and just created a new ad. Once you do, you get some interesting choices:

Note the Device type drop down. This has two options: “iPhones and other highend devices” and “All phones”. It’s nice that Google simplifies this. You can get more details here if you care. The only odd thing about the drop down is the lack of mention for Android. I’d have said “iPhones, Android, and other highend devices”. Ad size options are a bit limited, but this is to be expected.

Once done, you get a chunk of JavaScript code, just like you would for any regular ad:

<script type="text/javascript"><!-- // XHTML should not attempt to parse these strings, declare them CDATA. /* <![CDATA[ */ window.googleAfmcRequest = { client: 'ca-mb-pub-1736437642005360', format: '320x50_mb', output: 'html', slotname: '8053234936', }; /* ]]> */ //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_afmc_ads.js"></script>

That’s my own code there but you can feel free to use it with your own sites. ;) I decided to whip up a quick application to see how well this works. Not surprisingly, once I dropped in the code, it just worked. For my application I created a “Misfortune Cookie” generator, which simply picks a random (and sad) fortune to share. I spent all of ten minutes on this, but my son and friends loved it.

The ad choices seem a bit limited. There you can see it is a Google ad. I’ve seen medical ads as well as financial ones.

The only part that was semi-difficult was getting the ad to the bottom of the screen. I wrapped the ad code in a div that began like so:

<div style=";position:absolute;bottom:0;left:0;">

If you want to play with this app, you can download it here. I’m not supposed to ask people to click on ads. So I won’t do it. But I’ll happily report back on earnings if folks do click on the ads. But I’m not asking you to. M’kay?

One thing I want to stress here is that this is an experiment. To be honest, I don’t know if I was supposed to even use this ad format on a ‘native’ application. This may be totally against the rules, and if so, well, it was a fun experiment at least. If anyone wants the complete code, just ask. The Misfortune Generator is simply an array of strings that I pick randomly from.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments