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 ads to an ad unit's mediation configuration, how to set up Automatic data collection, and how to integrate the InMobi SDK and adapter into an Android app.

Supported formats and features

The Google Ad Manager mediation adapter for InMobi has the following capabilities:

Formats
Banners
Interstitials
Rewarded Video
Rewarded Video (new APIs)
Native Ads - Custom Rendering
Features
Smart Banners
Automatic data collection
Native Video

Requirements

  • Android API level 15 or later
  • Google Play services 17.2.0 or later

Step 1: Set up InMobi

Sign up or log in to your InMobi account.

Add an app

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

Enter your app's URL and click the Look Up button. Otherwise click Have an app that isn't yet published?

Enter the name of your app and choose Android 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

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

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

Interstitial

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

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 Ad Manager ad unit.

Rewarded Video

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

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 Ad Manager ad unit. Enter values for Key and Value for the reward details.

Native

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

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 Ad Manager ad unit. Select either PREROLL, STREAM, or SPLASH as the Native Ad Layout style and click Customize.

The 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.

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


Account ID

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

Next, you will get your Account ID, which can be found by clicking on your email address (located in the top-right corner of your InMobi dashboard).

In addition to your Account ID and Placement ID you need a secret key provided by InMobi. Contact the InMobi support team to obtain your key.

Step 2: Configure mediation settings for your Ad Manager ad unit

Sign in to your Ad Manager account. Navigate to Delivery > Yield groups and click the New yield group button.

Enter a unique Name for your yield group, set the Status to Active, select your Ad Format, and set the Inventory type to Mobile App. Under the Targeting > Inventory section, select the Ad Unit ID to which you want to add mediation.

Next, click the Add yield partner button.

If you already have a Yield partner for InMobi, you can simply select it. Otherwise, select Create a new yield partner.

Select InMobi as the Ad network and enter a unique Name. Enable Mediation and turn on Automatic data collection, and enter the Secret Key obtained from InMobi support. Next, enter your Username and click Save when done.

Once the Yield partner is selected, choose Mobile SDK mediation as the Integration type, Android as the Platform, and Active as the Status. Enter the Account ID and the Placement ID obtained in the previous section and a Default CPM value.

Click Save at the bottom of the page when done.

Using rewarded video ads

In the settings for your rewarded video ad unit, provide values for the reward amount and reward type. Then, to ensure you provide the same reward to the user no matter which ad network is served, check the Override reward settings from third-party ad networks when using mediation box.

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

Step 3: Import the InMobi SDK and adapter

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

repositories {
    jcenter()
}

...
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.android.gms:play-services-ads:19.0.1'
    implementation 'com.google.ads.mediation:inmobi:9.0.2.0'
}
...

Migrate project to AndroidX

The InMobi SDK depends on Android support libraries but the latest Google Mobile Ads SDK uses Jetpack libraries.

To ensure the InMobi SDK and the Google Mobile Ads SDK are compatible, create a gradle.properties file in the top-level of your project, and add the following code:

android.useAndroidX=true
android.enableJetifier=true

This will rewrite the InMobi SDK binary to use use Jetpack libraries. See AndroidX migration guide for more information about these settings.

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

No additional code is required for InMobi integration.

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.

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

Optional steps

Under the Google EU User Consent Policy, you must ensure that certain disclosures are given to, and consents obtained from, users in the European Economic Area (EEA) regarding the use of device identifiers and personal data. This policy reflects the requirements of the EU ePrivacy Directive and the General Data Protection Regulation (GDPR). When seeking consent, you must identify each ad network in your mediation chain that may collect, receive, or use personal data and provide information about each network's use. Google currently is unable to pass the user's consent choice to such networks automatically.

The section below shows you how to enable or disable personalized ads for InMobi.

In version 7.1.0.0, the InMobi adapter added the InMobiConsent class that allows you to pass consent information to InMobi. The following sample code calls updateGDPRConsent() on the InMobiConsent class. If you choose to call this method, it is recommended that you do so prior to requesting ads via the Google Mobile Ads SDK.

import com.inmobi.sdk.InMobiSdk;
import com.google.ads.mediation.inmobi.InMobiConsent;
// ...

JSONObject consentObject = new JSONObject();
try {
  consentObject.put(InMobiSdk.IM_GDPR_CONSENT_AVAILABLE, true);
  consentObject.put("gdpr", "1");
} catch (JSONException exception) {
  exception.printStackTrace();
}

InMobiConsent.updateGDPRConsent(consentObject);

See InMobi's GDPR implementation details for more information about the possible keys and values that InMobi accepts in this consent object.

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 that can be passed to the adapter as an Android Bundle. The adapter looks for the following keys in the bundle:

Request parameters and values
InMobiNetworkKeys.AGE_GROUP
The user's age group.
InMobiNetworkValues.BELOW_18
InMobiNetworkValues.BETWEEN_18_AND_24
InMobiNetworkValues.BETWEEN_25_AND_29
InMobiNetworkValues.BETWEEN_30_AND_34
InMobiNetworkValues.BETWEEN_35_AND_44
InMobiNetworkValues.BETWEEN_45_AND_54
InMobiNetworkValues.BETWEEN_55_AND_65
InMobiNetworkValues.ABOVE_65
InMobiNetworkKeys.EDUCATION
The user's education level.
InMobiNetworkValues.EDUCATION_HIGHSCHOOLORLESS
InMobiNetworkValues.EDUCATION_COLLEGEORGRADUATE
InMobiNetworkValues.EDUCATION_POSTGRADUATEORABOVE
InMobiNetworkKeys.AGE String. The age of the user
InMobiNetworkKeys.POSTAL_CODE String. The user's postal code (usually a five-digit number)
InMobiNetworkKeys.AREA_CODE String. The user's area code (part of the telephone number)
InMobiNetworkKeys.LANGUAGE String. The user's native language (if known).
InMobiNetworkKeys.CITY String. The user's city
InMobiNetworkKeys.STATE String. The user's state
InMobiNetworkKeys.COUNTRY String. The user's country
InMobiNetworkKeys.LOGLEVEL
Sets the Log level for InMobi SDK.
InMobiNetworkValues.LOGLEVEL_NONE
InMobiNetworkValues.LOGLEVEL_DEBUG
InMobiNetworkValues.LOGLEVEL_ERROR
Here's a code example of how to set these ad request parameters:

JAVA

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

KOTLIN

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

Using native ads

Ad rendering

The InMobi adapter returns its native ads as UnifiedNativeAd objects. It populates the fields described in Custom native ad formats for a UnifiedNativeAd.
Field Assets always included by InMobi adapter
Headline
Image error
Body
App icon
Call to action
Star rating
Store
Price

Impression and click tracking

The Google Mobile Ads SDK uses the InMobi SDK's callbacks for impression and click tracking, so the reports on both dashboards should match up with few to no discrepancies.

Media views

InMobi does not provide an image asset for any native ads (video or static). For non-video ads, InMobi's SDK populates its media view with an image asset instead. To avoid potential null pointer errors, the InMobi adapter automatically creates a blank NativeAd.Image and includes it in the images asset array that's part of the ad object received by the app.

Publishers mediating to InMobi are encouraged to avoid using the image assets directly, and instead use MediaView in their UI. Ads loaded via the InMobi adapter will always provide a media view, which will automatically display video assets for ads that contain them and an image asset for ads that don't.

InMobi Android Mediation Adapter Changelog

Version 9.0.2.0

  • Verified compatibility with InMobi SDK version 9.0.2.
  • Updated the minimum required Google Mobile Ads SDK version to 18.3.0.
  • Removed open bidding capability for banner, interstitial, and rewarded formats.
  • Fixed a bug that causes a crash when trying to render a native ad.

Built and tested with

  • Google Mobile Ads SDK version 18.3.0.
  • InMobi SDK version 9.0.2.

Version 7.3.0.1

  • Native ads now leverage the unified native ads mediation API.

Built and tested with

  • Google Mobile Ads SDK version 18.2.0.
  • InMobi SDK version 7.3.0.

Version 7.3.0.0

  • Verified compatibility with InMobi SDK version 7.3.0.
  • Updated the minimum required Google Mobile Ads SDK version to 18.2.0.

Version 7.2.9.0

  • Added open bidding capability to the adapter for banner, interstitial and rewarded ads.
  • Verified compatibility with InMobi SDK version 7.2.9.
  • Updated the minimum required Google Mobile Ads SDK version to 18.1.1.

Version 7.2.7.0

  • Verified compatibility with InMobi SDK version 7.2.7.

Version 7.2.2.2

  • Added support for flexible banner ad sizes.

Version 7.2.2.1

  • Updated adapter to support new open-beta Rewarded API.
  • Updated the minimum required Google Mobile Ads SDK version to 17.2.0.

Version 7.2.2.0

  • Verified compatibility with InMobi SDK version 7.2.2.

Version 7.2.1.0

  • Verified compatibility with InMobi SDK version 7.2.1.

Version 7.2.0.0

  • Verified compatibility with InMobi SDK version 7.2.0.

Version 7.1.1.1

  • Updated the adapter to invoke the onRewardedVideoComplete ad event.

Version 7.1.1.0

  • Verified compatibility with InMobi SDK version 7.1.1.

Version 7.1.0.0

  • Added InMobiConsent class which provides updateGDPRConsent() and getConsentObj() methods.
  • Verified compatibility with InMobi SDK version 7.1.0.

Version 7.0.4.0

  • Verified compatibility with InMobi SDK version 7.0.4.

Version 7.0.2.0

  • Verified compatibility with InMobi SDK version 7.0.2.

Version 7.0.1.0

  • Updated the adapter to make it compatible with InMobi SDK version 7.0.1.
  • Added support for native video ads.
  • For native ads, a media view is always returned by the adapter. The adapter no longer returns an image asset, instead the media view will display an image for static native ads.
  • Updated the adapter project for Android Studio 3.0.

Version 6.2.4.0

  • Verified compatibility with InMobi SDK version 6.2.4.

Version 6.2.3.0

  • Changed the version naming system to [InMobi SDK version].[adapter patch version].

Earlier versions

  • Adds support for banners, interstitials, rewarded video and native ad formats.