Chartboost in die Vermittlung einbinden

This guide shows you how to use the Google Mobile Ads SDK to load and display ads from Chartboost using mediation, covering waterfall integrations. It covers how to add Chartboost to an ad unit's mediation configuration, and how to integrate the Chartboost SDK and adapter into an Android app.

Supported integrations and ad formats

The mediation adapter for Chartboost has the following capabilities:

Integration
Bidding
Waterfall
Formats
Banner
Interstitial
Rewarded
Native

Requirements

  • Android API level 21 or higher

Step 1: Set up configurations in Chartboost UI

注册 Chartboost 账号,并在账号通过验证后登录。 然后,转到应用管理标签页。

Chartboost 应用信息中心

点击 Add new app 按钮创建应用。

应用管理

填写表单的其余部分,然后点击 Add App(添加应用)按钮,完成应用。

新建应用表单

创建应用后,系统会将您定向到该应用的信息中心。记下应用的应用 ID应用签名

应用设置

Ad Manager 需要 Chartboost 用户 ID用户签名,用于设置您的 Ad Manager 广告单元 ID。您可以通过点击 Chartboost 界面中的 Chartboost 中介找到这些参数。

Chartboost 中介信息中心

转到资源 > API Explorer 标签页,并记下身份验证部分下的用户 ID用户签名

Chartboost API Explorer

开启测试模式

您可以为应用启用测试模式,方法是从 Chartboost 界面中转到应用管理标签页,从列表中选择您的应用,然后点击 Edit app settings(修改应用设置)。

修改应用设置

在应用的设置中,您可以开启/关闭应用的测试模式

Chartboost 测试模式

启用测试模式后,您可以使用之前创建的广告单元 ID 请求广告,并接收 Chartboost 测试广告。

在您能够收到 Chartboost 测试广告后,您的应用将会参与 Chartboost 的 Publisher App Review 审核。为了确保 Chartboost 能够正常使用创收功能,发布商应用审核需要获得 Chartboost 的批准。

Step 2: Set up Chartboost demand in Ad Manager UI

为广告单元配置中介设置

登录您的 Ad Manager 帐号

依次转到投放 > 收益组,然后点击新建收益组按钮。

为您的收益组输入一个独一无二的名称,将状态设为有效,选择广告格式,然后将广告资源类型设为移动应用。在定位 > 广告资源部分下,选择广告资源移动应用(您要向其中添加中介)下方的广告单元。

接下来,点击添加收益合作伙伴按钮。

如果您已有Chartboost的收益合作伙伴,可以选择它。否则,请选择创建新的收益合作伙伴

选择 Chartboost 作为广告联盟,输入一个具有唯一性的名称并启用中介

开启自动收集数据,然后输入在上一部分中获取的User ID and User Signature

选择收益合作伙伴后,选择移动 SDK 中介作为集成类型,选择 Android 作为平台,选择有效作为状态。输入在上一部分获得的App ID, App Signature and Ad Location 。然后,输入默认每千次展示费用值。

Chartboost 广告位置(已命名的位置)是一些简单的名称,代表您要在应用中展示广告的位置。Ad Manager 会向设置中指定的位置发送请求。请求发送后,Chartboost 会将该位置信息添加到其界面中,以供报告之用。

在 Chartboost 界面中,点击 Advanced Settings 方法,即可在 Basic Settings 页面中显示您的广告位置。如需了解详情,请参阅 Chartboost 命名的位置指南。

完成后,点击页面底部的保存

Add Chartboost to GDPR and US state regulations ad partners list

Folgen Sie den Schritten unter DSGVO-Einstellungen und Einstellungen zu Bestimmungen von US-Bundesstaaten um Chartboost in die Liste der Werbepartner gemäß DSGVO und US-Bundesstaaten auf der Ad Manager Benutzeroberfläche aufzunehmen.

Step 3: Import the Chartboost SDK and adapter

In your project-level settings.gradle.kts file, add the following repositories:

dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
    maven {
      url = uri("https://cboost.jfrog.io/artifactory/chartboost-ads/")
    }
  }
}

Then, in your app-level build.gradle.kts file, add the following implementation dependencies and configurations. Use the latest versions of the Chartboost SDK and adapter:

dependencies {
    implementation("com.google.android.gms:play-services-ads:23.2.0")
    implementation("com.google.ads.mediation:chartboost:9.7.0.0")
}

Manual integration

  1. Download the .aar file of the latest version of the Chartboost SDK from Maven Central, and add it to your project.

  2. Navigate to the Chartboost adapter artifacts on Google's Maven Repository. Select the latest version, download the Chartboost adapter's .aar file, and add it to your project.

Step 4: Implement privacy settings on Chartboost SDK

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.

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 through 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 and their Android Privacy Methods for more details and the values that can be provided in each method.

US states privacy laws

U.S. states privacy laws require giving users the right to opt out of the "sale" of their "personal information" (as the law defines those terms), with the opt-out offered via a prominent "Do Not Sell My Personal Information" link on the "selling" party's homepage. The U.S. states privacy laws compliance guide offers the ability to enable restricted data processing for Google ad serving, but Google is unable to apply this setting to each ad network in your mediation chain. Therefore, you must identify each ad network in your mediation chain that may participate in the sale of personal information and follow guidance from each of those networks to ensure compliance.

In SDK version 8.1.0, Chartboost added the addDataUseConsent() method. The following sample code sets data use consent to OPT_IN_SALE. If you choose to call this method, it is recommended that you do so prior to requesting ads through the Google Mobile Ads SDK.

Java

DataUseConsent dataUseConsent = new CCPA(CCPA.CCPA_CONSENT.OPT_IN_SALE);
Chartboost.addDataUseConsent(context, dataUseConsent);

Kotlin

val dataUseConsent = CCPA(CCPA.CCPA_CONSENT.OPT_IN_SALE)
Chartboost.addDataUseConsent(context, dataUseConsent)

See Chartboost's CCPA article and their Android Privacy Methods for more details and the values that can be provided in each method.

Step 5: Add required code

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 6: Test your implementation

启用测试广告

请务必为Ad Manager 注册您的测试设备,并在 Chartboost 界面中启用测试模式

验证测试广告

如需验证您收到的是来自Chartboost的测试广告,请使用相应广告来源在广告检查器中启用单一广告来源测试Chartboost (Waterfall)

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.READ_PHONE_STATE" />

Error codes

If the adapter fails to receive an ad from Chartboost, you can check the underlying error from the ad response using ResponseInfo.getAdapterResponses() under the following classes:

com.google.ads.mediation.chartboost.ChartboostAdapter
com.google.ads.mediation.chartboost.ChartboostMediationAdapter

Here are the codes and accompanying messages thrown by the Chartboost adapter when an ad fails to load:

Error code Reason
0-99 Chartboost SDK returned an error. See Chartboost's documentation for more details.
101 The requested ad size does not match a Chartboost supported banner size.
102 Chartboost can only load 1 ad per location at a time.
103 Chartboost server parameters configured in the Ad Manager UI are missing/invalid.
104 The Chartboost interstitial or rewarded ad is not ready to be shown.

Chartboost Android Mediation Adapter Changelog

Version 9.7.0.0

  • Verified compatibility with Chartboost SDK version 9.7.0.
  • Updated the minimum required Google Mobile Ads SDK version to 23.0.0.

Built and tested with:

  • Google Mobile Ads SDK version 23.0.0.
  • Chartboost SDK version 9.7.0.

Version 9.6.1.0

  • Verified compatibility with Chartboost SDK version 9.6.1.

Built and tested with:

  • Google Mobile Ads SDK version 22.6.0.
  • Chartboost SDK version 9.6.1.

Version 9.6.0.0

  • Verified compatibility with Chartboost SDK version 9.6.0.

Built and tested with:

  • Google Mobile Ads SDK version 22.5.0.
  • Chartboost SDK version 9.6.0.

Version 9.5.0.0

  • Verified compatibility with Chartboost SDK version 9.5.0.

Built and tested with:

  • Google Mobile Ads SDK version 22.3.0.
  • Chartboost SDK version 9.5.0.

Version 9.4.1.0

  • Verified compatibility with Chartboost SDK version 9.4.1.

Built and tested with:

  • Google Mobile Ads SDK version 22.2.0.
  • Chartboost SDK version 9.4.1.

Version 9.4.0.0

  • Verified compatibility with Chartboost SDK version 9.4.0.

Built and tested with:

  • Google Mobile Ads SDK version 22.1.0.
  • Chartboost SDK version 9.4.0.

Version 9.3.1.0

  • Verified compatibility with Chartboost SDK version 9.3.1.

Built and tested with:

  • Google Mobile Ads SDK version 22.1.0.
  • Chartboost SDK version 9.3.1.

Version 9.3.0.0

  • Verified compatibility with Chartboost SDK version 9.3.0.

Built and tested with:

  • Google Mobile Ads SDK version 22.0.0.
  • Chartboost SDK version 9.3.0.

Version 9.2.1.1

  • Updated adapter to use new VersionInfo class.
  • Updated the minimum required Google Mobile Ads SDK version to 22.0.0.

Built and tested with:

  • Google Mobile Ads SDK version 22.0.0.
  • Chartboost SDK version 9.2.1.

Version 9.2.1.0

  • Verified compatibility with Chartboost SDK 9.2.1.

Built and tested with:

  • Google Mobile Ads SDK version 21.5.0.
  • Chartboost SDK version 9.2.1.

Version 9.2.0.0

  • Verified compatibility with Chartboost SDK 9.2.0.
  • Updated the minimum required Google Mobile Ads SDK version to 21.5.0.

Built and tested with:

  • Google Mobile Ads SDK version 21.5.0.
  • Chartboost SDK version 9.2.0.

Version 9.1.1.0

  • Added the ChartboostMediationAdapter.setAppParams(String, String) method as an optional way to hardcode which app ID and app signature to use to initialize the Chartboost SDK.
  • Verified compatibility with Chartboost SDK 9.1.1.
  • Updated the minimum required Google Mobile Ads SDK version to 21.3.0.

Built and tested with:

  • Google Mobile Ads SDK version 21.3.0.
  • Chartboost SDK version 9.1.1.

Version 8.4.3.1

  • Updated the minimum required Google Mobile Ads SDK version to 21.0.0.
  • Updated the minimum required Android API level to 19.

Built and tested with:

  • Google Mobile Ads SDK version 21.0.0.
  • Chartboost SDK version 8.4.3.

Version 8.4.3.0

  • Verified compatibility with Chartboost SDK 8.4.3.

Built and tested with:

  • Google Mobile Ads SDK version 20.6.0.
  • Chartboost SDK version 8.4.3.

Version 8.4.2.0

  • Verified compatibility with Chartboost SDK 8.4.2.
  • Updated compileSdkVersion and targetSdkVersion to API 31.
  • Updated the minimum required Google Mobile Ads SDK version to 20.6.0.

Built and tested with:

  • Google Mobile Ads SDK version 20.6.0.
  • Chartboost SDK version 8.4.2.

Version 8.4.1.0

  • Verified compatibility with Chartboost SDK 8.4.1.
  • Updated the minimum required Google Mobile Ads SDK version to 20.6.0.

Built and tested with:

  • Google Mobile Ads SDK version 20.6.0.
  • Chartboost SDK version 8.4.1.

Version 8.3.1.0

  • Verified compatibility with Chartboost SDK 8.3.1.
  • Updated the adapter to use new AdError API.

Built and tested with:

  • Google Mobile Ads SDK version 20.5.0.
  • Chartboost SDK version 8.3.1.

Version 8.3.0.0

  • Verified compatibility with Chartboost SDK 8.3.0.
  • Updated the minimum required Google Mobile Ads SDK version to 20.5.0.

Built and tested with:

  • Google Mobile Ads SDK version 20.5.0.
  • Chartboost SDK version 8.3.0.

Version 8.2.1.0

  • Verified compatibility with Chartboost SDK 8.2.1.
  • Updated the minimum required Google Mobile Ads SDK version to 20.1.0.

Built and tested with:

  • Google Mobile Ads SDK version 20.1.0.
  • Chartboost SDK version 8.2.1.

Version 8.2.0.1

  • Updated the minimum required Google Mobile Ads SDK version to 20.0.0.

Built and tested with:

  • Google Mobile Ads SDK version 20.0.0.
  • Chartboost SDK version 8.2.0.

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.