Tutorial: Using Multiple Ad Networks

Share on Facebook0Share on Google+6Tweet about this on TwitterShare on LinkedIn4

iap-featNearly all developers want to make money from their apps. For some, it’s their living, and for hobbyists, a little monetization can help offset expenses. To address the needs of all our developers, we offer four distinct subscription tiers. All Corona users can publish and sell their apps for a fixed price, but for those who prefer the freemium with ads model, there are a few challenges to be aware of. One of these challenges is a metric known as fill rate.

Fill rate is essentially a measure of inventory and it represents the advertising sold to ad buyers which, in turn, can be shown in your app. Ideally, you’d prefer that the end user sees an ad every time the app requests one, but often the ad vendor won’t have any inventory available. If the ad vendor can only provide 3 ads in 10 calls, that translates to a fill rate of 30%. The trouble is, that if you only show ads to users 30% of the time, you’re not maximizing your income potential.

Using Multiple Ad Vendors

One way to help maximize your fill rate is to use multiple ad vendors. At a glance, this is a tricky concept because the app must attempt to load an ad, and then attempt to load another if the first request was not filled. So, how long do you wait and how many times do you try to get an ad? How do you prioritize which ad vendors to use, and in what order? We discussed the fill rate metric, but this changes from day to day, making it difficult to adjust for.

Another metric to consider is eCPM or “effective cost per mill.” This term comes from the measure called “CPM” which is defined as the amount of money you (the developer) receive for delivering 1,000 ads. Advertisers eventually discovered that simply delivering ads didn’t benefit them, so they switched to a measure called CPC or “cost per click.” Now there are even newer measures around which ads are sold, including CPI or “cost per install.” Because ads can come from any of these sale types, they are normalized into an “effective CPM” value so that you can compare services and decide which ad vendor(s) you want to support.

Configuring the Ads Plugin

Once you know which vendors you want to utilize, you should program your app to handle them. Since most ad providers are configured via the plugin interface, you must include the various plugin entries in your build.settings file, for example:

In this example, the code brings in three vendors: Vungle video ads, Apple iAds and Google AdMob ads. The supportedPlatforms line for iAds tells the system that those ads will only work on iOS builds (iAds is not available for Android).

Initializing the Providers

When using multiple vendors, you must call ads.init() for each provider. This call requires a vendor code, an AppID string (provided by the ad vendor), and a function to handle the ad delivery event (or lack thereof). You can initialize as many ad providers as necessary, but you can only set up each provider once.

Coding the Callback Listeners

Next, you have to write callback listener functions to know if ads are displayed or not. The basic concept is to detect if an ad is not delivered and, if so, request an ad from another vendor. As a backup in the rare instance that all vendors fail to deliver an ad, you may consider implementing a self-promotional “ad” for your other apps.

In this series of functions, we request an ad from the first vendor. If the callback function reports an isError event, we call the next ad vendor. If that vendor fails to deliver an ad, we move to the third provider, and so forth. In this example, we actually stop after two attempts and show our local “promo scene.”

Starting the Ad Chain

To begin the delivery chain, simply set the first vendor as the current provider and call ads.show():

Notice that we use the method setCurrentProvider() to switch between ad vendors. This call should be at a logical point in your code flow — for example, if using interstitial (full-screen) ads, this should be at a convenient break point between levels/scenes, at the end of a game round, etc.

If you use this method for banner ads, be aware that some banner’s will update after a number of seconds, even a failed call will try again. It might be wise to call ads.hide() before changing providers to stop the first provider from trying to show an ad over top of another vendor.

In Summary

With the ability to use multiple ad vendors, you can significantly increase the ad fill rate in your apps. This, combined with other monetization methods like in-app purchases, increases your chances for revenue gain and overall success in the mobile market.

Share on Facebook0Share on Google+6Tweet about this on TwitterShare on LinkedIn4
Rob Miracle

Rob Miracle creates mobile apps for his own enjoyment and the amusement of others. He serves the Corona Community in the forums, on the blog, and at local events.

This entry has 7 replies

  1. develephant says:

    Perfect timing. Thanks.

  2. deniz says:

    Hi Rob, great tutorial, thank you. Also I must point that those additions to Corona regarding ad capabilities make my own homebrew ad mediation module almost useless, but I really appreciate that 🙂

    Nowadays I am playing with admob plugin heavily, and encounter some nasty bugs especially on Android platform.
    If you call ads.show() and right after that (in a fraction of a second) push home button to suspend the app, the next ads.show() call (and all other calls in the life time of the application) never succeeds, ie you dont get any banners, also event handlers never get called again. The weird thing is; also the native web popups stop to work. They dont show any web content.

    I know that here is not the right place to report any problems, but i want to just mention it. Thanks again.

  3. Joe says:

    Great article. Thanks.

  4. Great article. Thanks very much, putting in place at this very moment.

  5. Just a heads up.

    When setting the provider to “iAds” as above, the value should in fact be “iads” (lowercase).

    I had it camel case but it didn’t work. I changed it to lower case and it worked.

  6. kuldeep says:

    how to install admob Plugin