Integrating Chartboost with Mediation

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

Supported ad formats and features

The AdMob mediation adapter for Chartboost has the following capabilities:

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

Requirements

  • Android SDK 4.0 (API level 14) or later
  • Google Play services 8.3 or later

Step 1: Set up Chartboost

Sign up for a Chartboost account and log in once your account is verified. Click the + APP button on the left sidebar. Fill out the form and click save to add your app to Chartboost.

Chartboost add app

Create a new campaign to enable ads for your app. To create a new campaign navigate to Campaigns > Publishing from the left-side menu and click Add a Campaign (or + Add Campaign at the top right corner of your dashboard if you already have other campaigns) and choose Network Publishing when prompted.

Chartboost add campaign

Enter a Name for your publishing campaign, select the Ad Type, select Google Play as the Platform and then add your app to the Apps Publishing this Campaign. Click Save to finish adding the campaign.

Chartboost campaign

You will now obtain all the parameters that will be used in setting up the ad unit ID in the next section. In your Chartboost dashboard for your app, navigate to App Settings > Basic Settings to locate your App ID and App Signature.

Chartboost app settings

AdMob requires the Chartboost User ID and User Signature for setting up your AdMob ad unit ID. You can find these parameters on your Chartboost dashboard by navigating to Tools > API Explorer. Your User ID and User Signature are located under the Authentication section.

Chartboost api explorer

Step 2: Configure mediation settings for your AdMob ad unit

You need to add Chartboost to the mediation configuration for your ad unit. First sign in to 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

Navigate to the Monetize tab and select your app from the list of All apps on the left-hand side. Click the link in the mediation column for the ad unit you want to mediate to Chartboost.

Chartboost ad unit

Click + NEW AD NETWORK.

Chartboost ad network

Select Chartboost from the list of networks provided and enter the App ID and the App Signature obtained in the previous section. Also, enter an Ad Location (e.g. "Game Over Screen") that uniquely identifies this placement in your app.

Chartboost select chartboost

Chartboost Ad Locations (Named Locations) are simple names representing a place in your app where you want to show an ad. AdMob sends requests to the location specified in the settings. Once requests are sent, Chartboost will add the location to its dashboard for reporting purposes. If no location value is provided, AdMob uses "Default" as the location. It is recommended to avoid using "Default" so that AdMob ANO can calculate the Chartboost CPM with enough granularity for optimization purposes.

In the Chartboost dashboard, your Ad Locations can be revealed in the Basic Settings page by clicking on Advanced Settings. Please see the Chartboost's Named Locations guide for more details.

Next, add the User ID and the User Signature obtained in the previous section to set up ANO for Chartboost.

Click Continue at the bottom of the page to complete adding the network. Enter an eCPM value for Chartboost 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 Chartboost as an ad source.

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

AdMob Beta mediation tab

Enter 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, which will open up the ad unit selection overlay.

New mediation group 2

Associate this mediation group with your existing AdMob ad unit. Then click Done.

Select ad unit

You should now see the ad units card populated with the ad units you selected.

Mediation group ad units

Add Chartboost as an ad source

In the Ad Sources card, select Add Ad Network. Then select Chartboost.

Enable the Optimize switch. Enter your User ID and User Signature obtained in the previous section to set up ANO for Chartboost. Then enter an eCPM value for Chartboost and click Continue.

Next, enter the App ID and the App Signature obtained in the previous section. Also, enter an Ad Location (e.g. "Game Over Screen") that uniquely identifies this placement in your app.

Configure Chartboost ad unit

Chartboost Ad Locations (Named Locations) are simple names representing a place in your app where you want to show an ad. AdMob sends requests to the location specified in the settings. Once requests are sent, Chartboost will add the location to its dashboard for reporting purposes. If no location value is provided, AdMob uses "Default" as the location. It is recommended to avoid using "Default" so that AdMob ANO can calculate the Chartboost CPM with enough granularity for optimization purposes.

In the Chartboost dashboard, your Ad Locations can be revealed in the Basic Settings page by clicking on Advanced Settings. Please see the Chartboost's Named Locations guide for more details.

Finally, click Done to add Chartboost as an ad source, and then click Save.

Using rewarded video ads

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.

Mediation override reward

If you don't override the reward, the Chartboost adapter passes back the reward specified in the Chartboost UI.

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

Step 3: Import the Chartboost SDK and adapter

Download the latest version of the Chartboost SDK. Find the chartboost.jar file under lib/ folder and add it to your project's libs folder (create a libs folder and add the jar file if you don't have one).

Add the compile dependency with the latest version of the Chartboost adapter in the build.gradle file:

...
dependencies {
    compile 'com.android.support:appcompat-v7:xx.x.x'
    compile 'com.google.android.gms:play-services-ads:11.4.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.ads.mediation:chartboost:7.0.0.0'
}
...

Manual integration

Download the latest version of the Chartboost SDK. Add the chartboost.jar file to your project.

Download the latest Chartboost adapter from Bintray, located under the Files tab, and add it to your project.

Step 4: Additional code required

Modify AndroidManifest

Activities

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

<activity android:name="com.chartboost.sdk.CBImpressionActivity"
          android:excludeFromRecents="true"
          android:hardwareAccelerated="true"
          android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
          android:configChanges="keyboardHidden|orientation|screenSize" />

Other elements

Add the following attribute to each activity in the AndroidManifest.xml file that will be showing Chartboost ads and supports different orientations:

android:configChanges="keyboardHidden|orientation|screenSize"

Lifecycle events

Per Chartboost's recommendation, Add the following code to all of your activity's lifecycle events that will be showing Chartboost ads.

@Override
public void onStart() {
    super.onStart();
    Chartboost.onStart(this);
}

@Override
public void onResume() {
    super.onResume();
    Chartboost.onResume(this);
}

@Override
public void onPause() {
    super.onPause();
    Chartboost.onPause(this);
}

@Override
public void onStop() {
    super.onStop();
    Chartboost.onStop(this);
}

@Override
public void onDestroy() {
    super.onDestroy();
    Chartboost.onDestroy(this);
}

@Override
public void onBackPressed() {
    // If an interstitial is on screen, close it.
    if (Chartboost.onBackPressed()) {
        return;
    } else {
        super.onBackPressed();
    }
}

Step 5: Test your implementation

Test ads can be enabled for your app from Chartboost's dashboard under the APP SETTINGS > Basic Settings as shown below.

Chartboost test mode

Once test mode is enabled, you can request ads using the ad unit ID created earlier and receive a Chartboost test ad.

That's it! You now have a working mediation integration with Chartboost.

Optional steps

Permissions

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

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Using interstitial and rewarded video ads

Network-specific parameters

The Chartboost adapter supports an additional request parameter for interstitial and rewarded video ads which can be passed to the adapter using the ChartboostExtrasBundleBuilder class. The ChartboostExtrasBundleBuilder includes the following method:

  • setFramework(CBFramework, versionString) - Sets the framework info the app uses which allows Chartboost SDK to customize your requests for a specific framework.

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

Bundle bundle = new ChartboostAdapter.ChartboostExtrasBundleBuilder()
            .setFramework(CBFramework.CBFrameworkOther, "1.2.3")
            .build();
AdRequest adRequest = new AdRequest.Builder()
            .addNetworkExtrasBundle(ChartboostAdapter.class, bundle)
            .build();
adLoader.loadAd(adRequest);

Additional resources

发送以下问题的反馈:

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