Integrating InMobi with Mediation

This guide is intended for publishers who want to use the Google Mobile Ads SDK to load and display ads from InMobi via mediation. It covers how to add InMobi to an ad unit's mediation configuration, how to set up Ad Network Optimization (ANO), and integrate the InMobi SDK and adapter into an Android app.

Supported formats and features

The AdMob mediation adapter for InMobi has the following capabilities:

Formats
Banners
Interstitials
Rewarded Video
Native Advanced
Features
Smart Banners
Ad Network Optimization (ANO)

Requirements

  • Android API Level 15 or later
  • Google Play services 9.0.0 or later

Step 1: Set up InMobi

Sign up and log in to your InMobi account.

Figure: InMobi dashboard: Monetize tab

Click the Add an App button to add your app to InMobi.

Add an app

Figure: Add an App screen

Enter your app's URL and click the Look Up button if your app is already on the Play store. Otherwise click Have an app that isn't yet published?

Figure: Add an unpublished app

Enter the name of your app and choose iOS as the Platform. Select whether or not your app is COPPA compliant and click Add App when done.

Placements

InMobi requires you to create a placement before you finish adding your app.

Banner Ads

Figure: Create a Placement screen

Select BANNER as the type and enter a Placement Name. Click the Create Placement button when done.

Figure: Create a Placement details screen

Once the placement is created, its details are are shown. Take note of the Placement ID, which will be used for setting up your AdMob ad unit.

Interstitial Ads

Figure: Create a Placement screen

Select Interstitial as the type and enter a Placement Name for your placement. Click the Create Placement button when done.

Figure: Create a Placement details screen

Once the placement is created, the placement details are are shown. Take note of the Placement ID, which will be used for setting up your AdMob ad unit.

Rewarded Video Ads

Figure: Create a Placement screen

Select Rewarded Video as the type and enter a Placement Name for your placement. Click the Create Placement button when done.

Figure: Create a Placement details screen

Once the placement is created, its details are are shown. Take note of the Placement ID, which will be used later to set up your AdMob ad unit. Enter a value for Key and Value for the reward details.

Native Advanced Ads

Figure: Create a Placement screen

Select Native Content as the type and enter a Placement Name for your placement. Click the Create Placement button when done.

Figure: Create a Placement details screen

Once the placement is created, its details are are shown. Take note of the Placement ID, which will be used later to set up your AdMob ad unit. Select either TILE, STREAM or SPLASH as the Native Ad Layout style and click Customize.

FEED Native Ad Layout does not contain some of the assets that are required by Google Mobile Ads SDK and the adapter would fail the ad request if one of the required assets is missing.

Figure: Customize Native Ad Layout screen

Select the desired Screenshots (main image) size, then click Save.

Now that the placement has been created, click Proceed to Integration, then click Done.

Next, you will get your Account ID.

Figure: InMobi Account ID

Your Account ID can be located by clicking on your email address (located in the top right corner of your InMobi dashboard).

In addition to your Account ID and your Placement ID, you need a Secret Key. These are provided by InMobi. Contact the InMobi support team to obtain your key.

For InMobi SDK < 5

If you are using a version of the InMobi SDK lower than 5.0.0, you need an App ID instead of the Account ID and Placement ID to setup AdMob ad unit for InMobi mediation.

To get your App ID, open your app's Configuration page by clicking on your App's name in the InMobi dashboard's home page.

Figure: App configuration screen

Your App ID can be located under the app name at the top of the page.

Step 2: Configure mediation settings for your AdMob ad unit

You need to add InMobi to the mediation configuration for your ad unit. First sign into your AdMob account.

Next, follow the instructions for either AdMob or AdMob Beta depending on which version of the AdMob UI you're using.

AdMob

Figure: Ad unit details screen

Navigate to Monetize tab and select your application from the list of all your applications on the left-hand side. Click the link in the mediation column for the ad unit to which you want to add InMobi.

Figure: Mediation details screen

Click NEW AD NETWORK. A list of supported ad networks will be shown.

Figure: Select ad networks screen

Select InMobi from the list of networks provided and enter the Account ID and the Placement ID obtained in the previous section.

  • For InMobi SDK 5.0 and later - Use Account ID and Placement ID.

  • For InMobi SDK versions prior to 5.0 - Use App ID (leave Account ID and Placement ID blank).

Enter your Login name and Password along with the Secret key obtained from InMobi support to set up ANO for InMobi.

Click Continue at the bottom of the page to complete adding the network. Enter an eCPM value for InMobi and click Save.

AdMob Beta

Navigate to the Mediation tab. If you have an existing mediation group you'd like to modify, click the name of that mediation group to edit it, and skip ahead to Add inMobi as an ad source.

Figure: Mediation details screen

To create a new mediation group, select Create Mediation Group.

Figure: New mediation group screen

Enter your ad format and platform, then click Continue.

Figure: New mediation group details screen

Give your mediation group a name, and select locations to target. Next, set the mediation group status to Enabled. Then click Add Ad Units.

Figure: Ad units selection overlay

Associate this mediation group with one or more of your existing AdMob ad units. Then click Done.

You should now see the ad units card populated with the ad units you selected as shown below:

Figure: Ad units card

Add InMobi as an ad source

In the Ad Sources card, select Add Ad Network.

Figure: Add ad network dialog

Select InMobi and enable the Optimize switch. Enter your Login name and Password along with the Secret key obtained in the previous section to set up ANO for InMobi. Then enter an eCPM value for inmobi and click Continue.

Figure: InMobi: Configure ad units screen

Enter the Account ID and the Placement ID obtained in the previous section.

  • For InMobi SDK 5.0 and later - Use Account ID and Placement ID.

  • For InMobi SDK versions prior to 5.0 - Use App ID (leave Account ID and Placement ID blank).

Using rewarded video ads

Figure: Ad unit setup screen

In the settings for your rewarded video ad unit, check the Override reward settings from third-party ad networks when using AdMob mediation so that you provide the same reward to the user no matter which ad network is served.

If you don't override the reward, the InMobi adapter passes back the reward specified in the InMobi dashboard when creating the placement.

For more information on setting reward values for AdMob ad units, see Create an ad unit.

Step 3: Import the InMobi SDK and adapter

Add the following compile dependency with the latest version of the InMobi SDK and adapter in the app-level build.gradle file:

InMobi requires Picasso and RecyclerView libraries to show interstitial ads.

...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:xx.x.x'
    compile ' com.google.android.gms:play-services-ads:11.4.2'
    compile 'com.inmobi.monetization:inmobi-ads:6.2.0'
    compile 'com.google.ads.mediation:inmobi:6.2.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:recyclerview-v7:xx.x.x'
}
...

Manual integration

Download the InMobi Android SDK and extract the inmobi-version.jar file under the libs folder and add it to your project.

Download the latest InMobi adapter .aar file from Bintray, and add it to your project.

Download the latest version of Picasso Android library and add the picasso-version.jar file to your project.

Android RecyclerView library is part of the v7 Support Libraries and can be located under your Android SDK directory. Extract the android-support-v7-recyclerview.jar file from [android-sdk-dir]/extras/android/support/v7/recyclerview/libs/ and add it to your project.

Step 4: Additional code required

Modify Android manifest

Activities

Include the following Activity tags in your AndroidManifest.xml under the application tag:

<activity
    android:name="com.inmobi.rendering.InMobiAdActivity"
    android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize|screenLayout"
    android:hardwareAccelerated="true"
    android:resizeableActivity="false"
    android:theme="@android:style/Theme.NoTitleBar"
    tools:ignore="UnusedAttribute" />

Other elements

Include the following Receiver tag in your AndroidManifest.xml under the application tag:

<receiver
     android:name="com.inmobi.commons.core.utilities.uid.
     ImIdShareBroadCastReceiver"
     android:enabled="true"
     android:exported="true"
     tools:ignore="ExportedReceiver">
          <intent-filter>
              <action android:name="com.inmobi.share.id"/>
          </intent-filter>
 </receiver>

Step 5: Test your implementation

To enable test ads for a placement, go to your app's details page by clicking on your App's name in the InMobi dashboard and navigate to the Placements tab located in the left navigation bar. Select the placement for which you want to enable test ads and click on the Diagnostics section to expand it.

Figure: Placement details - Diagnostics section

You can either choose Global ON or Selective ON as the Test Mode. If you selected Selective ON, you need to add a test device. Make sure that InMobi Test Ad is selected as the Test ad.

Optional steps

Permissions

For optimal performance, InMobi recommends adding the following optional permissions to your app's AndroidManifest.xml file.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

Network-specific parameters

The InMobi adapter supports additional request parameters which can be passed to the adapter as an Android Bundle. The adapter looks for the following keys in the bundle:

  • InMobiNetworkKeys.AGE_GROUP - The user's age group, can be one of the following values:
    • kIMSDKAgeGroupBelow18
    • InMobiNetworkValues.BELOW_18
    • InMobiNetworkValues.BETWEEN_18_AND_20
    • InMobiNetworkValues.BETWEEN_21_AND_24
    • InMobiNetworkValues.BETWEEN_25_AND_34
    • InMobiNetworkValues.BETWEEN_35_AND_54
    • InMobiNetworkValues.ABOVE_55
  • InMobiNetworkKeys.HOUSEHOLD_INCOME - The household income of user in US Dollars,can be one of the following values:
    • InMobiNetworkValues.ABOVE_USD_150K,
    • InMobiNetworkValues.BELOW_USD_5K,
    • InMobiNetworkValues.BETWEEN_USD_100K_AND_150K,
    • InMobiNetworkValues.BETWEEN_USD_10K_AND_15K,
    • InMobiNetworkValues.BETWEEN_USD_15K_AND_20K,
    • InMobiNetworkValues.BETWEEN_USD_20K_AND_25K,
    • InMobiNetworkValues.BETWEEN_USD_25K_AND_50K,
    • InMobiNetworkValues.BETWEEN_USD_50K_AND_75K,
    • InMobiNetworkValues.BETWEEN_USD_5K_AND_10K,
    • InMobiNetworkValues.BETWEEN_USD_75K_AND_100K
  • InMobiNetworkKeys.EDUCATION - The user's education level, can be one of the following values:
    • InMobiNetworkValues.EDUCATION_HIGHSCHOOLORLESS,
    • InMobiNetworkValues.EDUCATION_COLLEGEORGRADUATE,
    • InMobiNetworkValues.EDUCATION_POSTGRADUATEORABOVE
  • InMobiNetworkKeys.ETHNICITY - Ethnic group of the user, can be one of the following values:
    • InMobiNetworkValues.ETHNICITY_HISPANIC,
    • InMobiNetworkValues.ETHNICITY_AFRICAN_AMERICAN,
    • InMobiNetworkValues.ETHNICITY_CAUCASIAN,
    • InMobiNetworkValues.ETHNICITY_OTHER
  • InMobiNetworkKeys.INCOME- A String representing the approximate annual household income (in US Dollars) of the user.
  • InMobiNetworkKeys.AGE- A String representing the age of the user.
  • InMobiNetworkKeys.POSTAL_CODE - A String representing the postal code (usually a five-digit number).
  • InMobiNetworkKeys.AREA_CODE - A String representing the area code (part of the telephone number).
  • InMobiNetworkKeys.LANGUAGE - A String representing the native language of the user (if known)
  • InMobiNetworkKeys.NATIONALITY - A String representing the Nationality of the user
  • InMobiNetworkKeys.CITY- A String representing the user's city
  • InMobiNetworkKeys.STATE- A String representing the user's state
  • InMobiNetworkKeys.COUNTRY- A String representing the user's country
  • InMobiNetworkKeys.LOGLEVEL - Sets the Log level for InMobi SDK, can be one of the following values.
    • InMobiNetworkValues.LOGLEVEL_NONE,
    • InMobiNetworkValues.LOGLEVEL_DEBUG,
    • InMobiNetworkValues.LOGLEVEL_ERROR

Here's a code example of how to set these ad request parameters:

Bundle extras = new Bundle();
extras.putString(InMobiNetworkKeys.AGE_GROUP,
InMobiNetworkValues.BETWEEN_35_AND_54);
extras.putString(InMobiNetworkKeys.AREA_CODE, "12345");
...
AdRequest request = new AdRequest.Builder()
            .addNetworkExtrasBundle(InMobiAdapter.class, extras)
            .build());

Using native ads

Ad rendering

The InMobi adapter populates the following fields for a NativeAppInstallAd:

Field Always included assets by InMobi adapter
Headline
Image
Body
App icon
Call to action
Star rating
Store
Price

Impression and click tracking

Google Mobile Ads SDK uses the InMobi SDK's callbacks for impression and click tracking, so the reports on both the dashboard should matchup with little to no discrepancies.

发送以下问题的反馈:

此网页
AdMob for Android
AdMob for Android
需要帮助?请访问我们的支持页面