Integrating InMobi with Open Bidding Mediation

This guide is for publishers who want to use the Google Mobile Ads SDK to load and display ads from InMobi via Open Bidding mediation. It covers how to add InMobi to an ad unit's mediation configuration and how to integrate the InMobi SDK and adapter into an Android app.

Supported formats and features

The Google AdMob mediation adapter for InMobi has the following capabilities:

Formats
Banners
Interstitials
Rewarded Video
Native Advanced
Features
Smart Banners

Requirements

  • Android API level 15 or later
  • Google Mobile Ads SDK 18.1.1 or higher
  • InMobi Android SDK version 7.2.9 or higher

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 are shown. Take note of the Placement ID, which will be used for setting up your AdMob 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 AdMob 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 AdMob ad unit. Enter values for Key and Value for the reward details.

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

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 in to your AdMob account.

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.

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

Select your ad format and platform, then click Continue.

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

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:

Add InMobi as an ad source

In the Ad Sources card, select Add Ad Network.

Select InMobi (Open Bidding). Then, enter the Account ID, as well as the Placement ID obtained in the previous section.

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 Apply to all networks in Mediation groups box.

If you don't apply this setting, 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 implementation dependencies with the latest version of the InMobi SDK and adapter in the app-level build.gradle file:

...
dependencies {
    implementation 'com.google.android.gms:play-services-ads:18.2.0'
    implementation 'com.google.ads.mediation:inmobi:7.3.0.0'
}
...

Step 4: Additional code required

No additional code is required for InMobi integration.

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");
...
AdRequest request = new AdRequest.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 = AdRequest.Builder()
        .addNetworkExtrasBundle(InMobiAdapter.class, extras)
        .build()