Posted on by

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, including those using the free Starter tier, 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:

plugins =
{
   ["CoronaProvider.ads.vungle"] =
   {
      publisherId = "com.vungle",
   },
   ["CoronaProvider.ads.iads"] =
   {
      publisherId = "com.coronalabs",
      supportedPlatforms = { iphone = true },
   },
   ["CoronaProvider.ads.admob"] =
   {
      publisherId = "com.coronalabs",
      supportedPlatforms = { android = true },
   },
},

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.

if ( system.getInfo("platformName") == "Android" ) then
   ads.init( "admob", "your-ad-unit-id-here", adMobListener )
else
   ads.init( "iads", "com.yourcompany.yourapp", iAdsListener )
end
ads.init( "vungle", "yourAppID", vungleListener )

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.

local function vungleListener( event )
   -- Video ad not yet downloaded and available
   if ( event.type == "adStart" and event.isError ) then
      if ( system.getInfo("platformName") == "Android" ) then
         ads:setCurrentProvider( "admob" )
      else
         ads:setCurrentProvider( "iAds" )
      end
      ads.show( "interstitial" )
   elseif ( event.type == "adEnd" ) then
      -- Ad was successfully shown and ended; hide the overlay so the app can resume.
      storyboard.hideOverlay()

   else
      print( "Received event", event.type )
   end
   return true
end

local function iAdsListener( event )
   if ( event.isError ) then
      storyboard.showOverlay( "selfpromo" )
   end
   return true
end

local function adMobListener( event )
   if ( event.isError ) then
      storyboard.showOverlay( "selfpromo" )
   end
   return true
end

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():

local params = {
   isAnimated = false,
   isAutoRotation = true,
}
ads:setCurrentProvider( "vungle" )
ads.show( "interstitial", params )

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.


Posted by . Thanks for reading...

4 Responses to “Tutorial: Using Multiple Ad Networks”

  1. deniz

    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.

    Reply

Leave a Reply

  • (Will Not Be Published)