Posted:

Smart banners are a handy thing for publishers. You can drop an AdMob smart banner into a layout or storyboard, and it’ll stretch or squeeze itself at runtime until it’s just the right size for the device, then request an ad to match. They’re a great feature with all the extra work hidden under the hood.

If you’re building an Android mediation adapter or custom event, though, things aren’t quite as simple -- after all, you’re under that hood, too! A common rough spot for developers is retrieving a smart banner’s size. Because the Google Mobile Ads SDK uses constants to internally represent a smart banner’s height and width, the getHeight and getWidth methods of a smart banner’s AdSize will return those constants (they’re negative numbers, so they’re quite hard to miss). That means relying on calls to getHeight and getWidth to determine a smart banner’s true size isn’t a workable strategy.

So how should adapter and custom event developers calculate sizes correctly? By avoiding getHeight and getWidth, and instead asking for pixel counts using getHeightInPixels and getWidthInPixels, two other methods offered by AdSize. You can scale their return values according to the device’s metrics and end up with the same kind of DPI values returned by getWidth and getHeight for other ad sizes. Here’s a code snippet that shows how it’s done:

// Get the raw pixel counts.
int widthInPixels = size.getWidthInPixels(context);
int heightInPixels = size.getHeightInPixels(context);

// These metrics include screen density, which is what we’re after.
DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();

// These are values you can send to your mediated network’s SDK.
int widthInDpi = Math.round(widthInPixels / displayMetrics.density);
int heightInDpi = Math.round(heightInPixels / displayMetrics.density);

Once you finish the math, you’ll have proper DPI values that can be sent to whichever network you’re mediating. The calls to getHeightInPixels and getWidthInPixels require a valid Context, but you can use the one provided as a parameter to the requestBannerAd methods in MediationBannerAdapter and CustomEventBanner.

Now you know the best way to gauge the size of a smart banner! Use this approach and it’ll help keep your mediation running smoothly.

If you have technical questions about this (or anything else relating to the Google Mobile Ads SDK) stop by our forum.

Posted:

Today, we’re excited to announce a new release to both our Android and iOS Google Mobile Ads SDKs. The key new features added in these releases are in-app purchase ads for both platforms and new mediation APIs for Android.

In-App Purchase Ads

In this release we’ve added SDK-level support (front-end support coming soon!) for running house ads that can initiate an in-app purchase. In-app purchase ads require that you set an in-app purchase listener on your interstitial ad. If an in-app purchase ad is shown, it will present the user with an option to buy one or more items that you have configured:

When the user clicks Buy now, the SDK will invoke your in-app purchase listener with the purchase information necessary to start a transaction for that product. You are responsible for implementing the in-app purchase flow from this point. Full implementation details can be found in our Android and iOS documentation.

Note: Front-end support for this feature is not available yet, but is coming soon.

New Mediation APIs

As part of our Google Play services API revamp, we’ve added new mediation APIs (which we’re calling mediation v2) to make it easier for ad networks to create mediation adapters.

Don’t worry! We’re still supporting mediation adapters written against mediation v1 APIs. This change won’t require any immediate updates to your apps.

If you previously passed extra parameters to third party networks, note that this process has changed for mediation v2. You’ll now pass a bundle to the ad network, keyed by its mediation v2 adapter class. Here is an example of passing extra parameters to AdMob:

Bundle adMobBundle = new Bundle();
adMobBundle.putString("color_bg", "AAAAFF");
AdRequest request = new AdRequest.Builder()
    .addNetworkExtrasBundle(AdMobAdapter.class, adMobBundle)
    .build();

You can also use this snippet to check for the existence of mediation v2 support. If this snippet compiles, then the adapter supports mediation v2. If there is a compilation error saying that the arguments don’t match the arguments for addNetworkExtrasBundle(Class extends MediationAdapter>, Bundle), then that adapter class does not support mediation v2.

See the documentation for more information on passing parameters to mediation v2.

Dropped Support for iOS 4.3

The 6.9.2 iOS SDK release has dropped support for iOS 4.3. By dropping iOS 4.3, the SDK can take advantage of automatic reference counting (ARC) weak references to provide a more stable release. The SDK still supports iOS 5.0 and above.

Check out the downloads page to grab the latest iOS release. A new Google Play services revision will soon be available in Android’s SDK Manager.

For a full list of SDK changes, see the release notes. If you have any technical questions about these changes, we’re available on the forum. Finally, stay tuned for an update on front-end support for in-app purchase ads on our Google+ page.

Posted:

We recently announced the ability to set an eCPM floor when making requests to the AdMob network. This post will show you how to set up this new feature to get the maximum benefit from the AdMob network.

First of all, we highly recommend that you create a new AdMob publisher ID on admob.com for each Mediation Placement you want to configure with AdMob eCPM floor. By creating a unique publisher ID, you’ll get fine grained reporting on how eCPM floor is performing on each of your placements.

Next, select Add Ad Network on your mediation placement, and add the AdMob eCPM Floor Beta network. In the Ad Network Configuration Settings, point this network to your newly created eCPM floor publisher ID.


Note: If you didn’t previously have a mediation placement, you’ll need to create a mediation placement on mediation.admob.com, and use the mediation placement ID in your application in place of your AdMob publisher ID.

Finally, you need to update your allocation to give the AdMob eCPM Floor Beta network an eCPM value. A suitable value for the eCPM floor is a value higher than the highest eCPM you’re getting from other networks.

In the sample below, Ad Network A is getting $0.37 eCPM. By setting AdMob eCPM Floor Beta slightly higher at $0.40, AdMob Mediation will first try to fetch an ad worth $0.40 eCPM from the AdMob Network. If it can’t fill that request, Mediation will try Ad network A, followed by Ad network B. If neither of those networks can fill the request, Mediation will come back to the AdMob network to fetch an ad without the eCPM floor restriction.


This new configuration will increase your ad revenue for requests fulfilled by AdMob eCPM Floor Beta, while still maintaining the same revenue from the rest of your requests where AdMob cannot fill the eCPM Floor request. You can also track your eCPM Floor performance by viewing sites and apps reporting for your newly created eCPM floor publisher ID.

If you have any questions about eCPM Floor or AdMob in general, please direct them to our forum. You can also follow us on our Google+ page to get updates on all Google ads developer products.

Posted:
Today, we’re giving AdMob developers more control over the value of ad impressions served to their apps. The AdMob eCPM Floor beta allows developers to set a minimum CPM they’d like to receive for each ad. The beta is available to AdMob developers who are using AdMob Mediation.

How does this work? Advertisers bid to show their ads on apps in the AdMob network, and an auction is run for every impression to determine the winner. We predict what the ‘expected CPM’ (eCPM) of that ad impression will be. The developer sets a minimum eCPM and we will only serve ads to their app that meet or exceed that level. For example, if a floor of $1.25 is set, we’ll only show ads with an eCPM of $1.25 or more. When choosing a floor value it’s important for developers to look at their own reporting and determine a value that’s relevant to them.

Here are a few details to know when taking part in the beta:
  • Make sure the eCPMs that are set for other ad networks are accurate.
  • We don’t guarantee the final value of the eCPM, since we don’t know if a user will click on the ad.
Developers who use the beta have the option of setting just one network line item in their mediation stack which uses the eCPM floor. Or, they can have two network line items, one that uses the eCPM floor and one without, so they can continue to fill impressions at their current fill rate. Setting the eCPM floor at a very high value will likely lead to a decrease in the fill rate.


Find setup instructions in the AdMob Help Center here under the article titled ‘Allocate traffic by eCPM’.

Posted by: Vishay Nihalani, Product Manager, Google

Posted:

Ad networks take into account a variety of signals when targeting ads to your users. Generally speaking, the more information you provide to an ad network, the more accurately that network can target its ads, and the better those ads perform.

Many parameters, such as age, gender, and location, are commonly used by most ad networks. AdMob Mediation supports passing those parameters directly in the AdRequest; these parameters will be passed to the networks you’re mediating:

AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
adRequest.setBirthday(new Date(2000, 1, 1));
adRequest.setGender(AdRequest.Gender.MALE);
adRequest.setLocation(location);

AdMob Mediation also supports passing specialized parameters to specific networks. Any custom parameters used by a specific ad network can be passed to an instance of that network adapter’s NetworkExtras object, which is then set on the AdRequest. Here is how you can customize the background and text colors for AdMob text ads, and set education level and number of children for a hypothetical Example ad network:

AdMobAdapterExtras adMobExtras = new AdMobAdapterExtras();
adMobExtras.addExtra("color_bg", "00FFFF");
adMobExtras.addExtra("color_text", "FF0000");
adRequest.setNetworkExtras(adMobExtras);

ExampleAdapterExtras exampleExtras = new ExampleAdapterExtras();
exampleExtras.setEducation(Education.BACHELORS);
exampleExtras.setNumberOfChildren(2);
adRequest.setNetworkExtras(exampleExtras);

AdMob Mediation will pass an adapter only the NetworkExtras object specific to that network. So in this case, the AdMob adapter will be provided with the AdMobAdapterExtras object, and the Example adapter will be provided with the ExampleAdapterExtras object. You can find the class name for each ad network’s NetworkExtras object in their respective adapter jar file.

Custom Events

You can also use CustomEventExtras to pass special parameters to any custom events that your app implements. Keep in mind that you can call AdRequest.setNetworkExtras() with only one instance of CustomEventExtras for all custom events that you implement. To make sure your custom event doesn’t access parameters meant for other custom events, we recommend you create a HashMap for each custom event, and pass in any necessary key-value pairs related to that custom event in that map.

CustomEventExtras customEventExtras = new CustomEventExtras();
HashMap customExtras1 = new HashMap();
customExtras1.put("key1", "value1");
customExtras1.put("key2", "value2");
customEventExtras.addExtra("customEvent1", customExtras1);
HashMap customExtras2 = new HashMap();
customExtras1.put("key1", "othervalue1");
customExtras1.put("key2", "othervalue2");
customEventExtras.addExtra("customEvent2", customExtras2);

Your custom event implementation just needs to check CustomEventExtras for the HashMap at whatever key that was designated for it - in this case customEvent1. You’ll use these parameters to construct your custom event.

HashMap extras =
    (HashMap) customEventExtras.getExtra("customEvent1");

Load the Ad

Once you’re done setting all targeting options, make sure to call loadAd with that request.

// This snippet assumes you have an AdView object named "adView".
adView.loadAd(adRequest);

If you have any questions or comments about AdMob, mediation, custom events, or targeting, we can field them in the forum. Also follow us on our Google+ page for ads-related updates.