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 | |
Rewarded Video (new APIs) | |
Native Advanced | |
Features | |
Smart Banners | |
Ad Network Optimization (ANO) |
Requirements
- Android SDK 5.0 (API level 21) or higher
- Latest Google Mobile Ads SDK
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.
Then, in your Chartboost dashboard for your app, navigate to App Settings > Basic Settings to locate your App ID and App Signature.
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.
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, 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.
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.
Associate this mediation group with your existing AdMob ad unit. Then click Done.
You should now see the ad units card populated with the ad units you selected.
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.
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.
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, 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 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
Android Studio integration (recommended)
Add the following Maven repository and the implementation dependencies with the
latest versions of the Chartboost SDK and adapter to your app-level
build.gradle
file:
... repositories { maven { url "https://chartboostmobile.bintray.com/Chartboost" } } dependencies { implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'com.google.android.gms:play-services-ads:19.6.0' implementation 'com.google.ads.mediation:chartboost:8.2.0.0' } ...
Manual integration
Download the latest version of the Chartboost SDK from Bintray, located under the Files tab, and add it 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
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.
Java
import com.chartboost.sdk.Chartboost;
// ...
@Override
public void onBackPressed() {
// If an interstitial is on screen, close it.
if (Chartboost.onBackPressed()) {
return;
} else {
super.onBackPressed();
}
}
Kotlin
import com.chartboost.sdk.Chartboost
// ...
@Override
fun 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.
Once test mode is enabled, you can request ads using the ad unit ID created earlier and receive a Chartboost test ad.
Step 6: Prepare app for production
After you are able to receive Chartboost test ads, your app will be placed on Chartboost's Publisher App Review. Once your app is approved, you can then create your Publishing Campaign to configure your app for live Chartboost ads.
Navigate to Monetization > Publishing Campaigns 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.
Enter a Name for your publishing campaign, select the Placement Type, and select Google Play as the Platform. If your app has been approved by Chartboost, you'll be able to select your app and apply it to this campaign. Fill out the rest of the form and click Save to finish adding the campaign.
That's it! You now have a working mediation integration with Chartboost.
Optional steps
EU consent and GDPR
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 Chartboost.
In SDK version 8.1.0, Chartboost
added
the addDataUseConsent()
method. The following sample code sets data
use consent to NON_BEHAVIORAL
. If you choose to call this method, it is
recommended that you do so prior to requesting ads via the Google
Mobile Ads SDK.
Java
DataUseConsent dataUseConsent = new GDPR(GDPR.GDPR_CONSENT.NON_BEHAVIORAL);
Chartboost.addDataUseConsent(context, dataUseConsent);
Kotlin
val dataUseConsent = GDPR(GDPR.GDPR_CONSENT.NON_BEHAVIORAL)
Chartboost.addDataUseConsent(context, dataUseConsent)
See Chartboost's GDPR article for more details.
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:
Java
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);
Kotlin
val bundle = ChartboostAdapter.ChartboostExtrasBundleBuilder()
.setFramework(CBFramework.CBFrameworkOther, "1.2.3")
.build()
val adRequest = AdRequest.Builder()
.addNetworkExtrasBundle(ChartboostAdapter::class.java, bundle)
.build()
adLoader.loadAd(adRequest)
Additional resources
- Start a Publishing Campaign provides additional details on how to set up Chartboost publishing campaigns.
Chartboost Android Mediation Adapter Changelog
Version 8.2.0.0
- Verified compatibility with Chartboost SDK 8.2.0.
- Updated the minimum required Google Mobile Ads SDK version to 19.5.0.
Built and tested with:
- Google Mobile Ads SDK version 19.5.0.
- Chartboost SDK version 8.2.0
Version 8.1.0.0
- Verified compatibility with Chartboost SDK 8.1.0.
Built and tested with:
- Google Mobile Ads SDK version 19.2.0.
- Chartboost SDK version 8.1.0
Version 8.0.3.2
- Added descriptive error codes and reasons for adapter load/show failures.
- Updated the minimum required Google Mobile Ads SDK version to 19.2.0.
Built and tested with:
- Google Mobile Ads SDK version 19.2.0.
- Chartboost SDK version 8.0.3.
Version 8.0.3.1
- Added support for Chartboost banner ads.
Built and tested with:
- Google Mobile Ads SDK version 19.1.0.
- Chartboost SDK version 8.0.3.
Version 8.0.3.0
- Verified compatibility with Chartboost SDK 8.0.3.
- Updated the minimum required Google Mobile Ads SDK version to 19.1.0.
Built and tested with:
- Google Mobile Ads SDK version 19.1.0.
- Chartboost SDK version 8.0.3.
Version 8.0.2.0
- Verified compatibility with Chartboost SDK 8.0.2.
- Updated the minimum required Google Mobile Ads SDK version to 19.0.1.
Built and tested with:
- Google Mobile Ads SDK version 19.0.1.
- Chartboost SDK version 8.0.2.
Version 8.0.1.0
- Verified compatibility with Chartboost SDK 8.0.1.
- Requires Chartboost SDK 8.0.1 or higher.
- Activity context is no longer required to load ads.
Built and tested with:
- Google Mobile Ads SDK version 18.3.0.
- Chartboost SDK version 8.0.1.
Version 7.5.0.1
- Fixed a bug where Chartboost adapter failed to invoke ad events.
- Updated the minimum required Google Mobile Ads SDK version to 18.3.0.
Built and tested with:
- Google Mobile Ads SDK version 18.3.0.
- Chartboost SDK version 7.5.0.
Version 7.5.0.0
- Verified compatibility with Chartboost SDK 7.5.0.
- Migrated the adapter to use AndroidX dependencies.
- Updated the minimum required Google Mobile Ads SDK version to 18.1.1.
Version 7.3.1.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.3.1.0
- Verified compatibility with Chartboost SDK 7.3.1.
Version 7.3.0.0
- Verified compatibility with Chartboost SDK 7.3.0.
Version 7.2.1.0
- Verified compatibility with Chartboost SDK 7.2.1.
Version 7.2.0.1
- Updated the adapter to invoke the
onRewardedVideoComplete()
ad event.
Version 7.2.0.0
- Verified compatibility with Chartboost SDK 7.2.0.
Version 7.1.0.0
- Verified compatibility with Chartboost SDK 7.1.0.
Version 7.0.1.0
- Verified compatibility with Chartboost SDK 7.0.1.
- Added support for new Chartboost error codes.
- Updated the Adapter project for Android Studio 3.0
Version 7.0.0.0
- Updated the adapter to make it compatible with Chartboost SDK 7.0.0.
Version 6.6.3.0
- Verified compatibility with Chartboost SDK 6.6.3.
Version 6.6.2.0
- Verified compatibility with Chartboost SDK 6.6.2.
Version 6.6.1.0
- Verified compatibility with Chartboost SDK 6.6.1.
Version 6.6.0.0
- Changed the version naming system to [Chartboost SDK version].[adapter patch version].
- The adapters can now be added as a compile dependency by adding the following
to the build.gradle file's dependencies tag:
compile 'com.google.ads.mediation:chartboost:6.6.0.0'
- Moved to distributing the adapter as an aar instead of a jar file (see README for additional instructions).
Version 1.1.0
- Removed Chartboost Ad Location from Chartboost extras. Ad Location is now specified in the AdMob console when configuring Chartboost for mediation.
Version 1.0.0
- Initial release. Supports reward-based video ads and interstitial ads.