Integrate myTarget with mediation

This guide shows you how to use GMA Next-Gen SDK to load and display ads from myTarget using mediation, covering waterfall integrations. It covers how to add myTarget to an ad unit's mediation configuration, and how to integrate the myTarget SDK and adapter into an Android app.

Supported integrations and ad formats

The mediation adapter for myTarget has the following capabilities:

Integration
Bidding
Waterfall
Formats
Banner
Interstitial
Rewarded
Native

Prerequisites

Before you continue, verify the following:

  • Android API level 24 or later.

Step 1: Set up configurations in myTarget UI

Log in to your myTarget account. Navigate to the Apps page by clicking on APPS on the header. Add your app by clicking ADD APP.

Next, provide the Google Play URL for your app.

When adding an app, myTarget requires you to create an ad unit before you can complete the process.

Select BANNER from the available ad formats, and then click the ADD AD UNIT button.

Interstitial

Select INTERSTITIAL from the available ad formats, and then click the ADD AD UNIT button.

Rewarded

Select REWARDED VIDEO from the available ad formats, and then click the ADD AD UNIT button.

Native

Select NATIVE from the available ad formats, and then click on ADD AD UNIT.

In your ad unit's details page, make a note of your slot ID which can be found under the ad unit settings as slot_id. This slot ID will be used to set up your Ad Manager ad unit in the next section.

In addition to the slot_id, you'll also need your myTarget Permanent Access Token to set up your AdMob ad unit ID. Navigate to the Profile tab and select Access Tokens. Click Create Token or Show Token to view your myTarget Permanent Access Token.

Update your app-ads.txt

Authorized Sellers for Apps app-ads.txt is an IAB Tech Lab initiative that helps ensure your app ad inventory is only sold through channels you've identified as authorized. To prevent a significant loss in ad revenue, you'll need to implement an app-ads.txt file. If you haven't done so already, create an app-ads.txt file for Ad Manager.

To implement app-ads.txt for myTarget, see How to create and publish a file.

Turn on test mode

Follow the instructions in myTarget's documentation to add and configure a test device in myTarget UI.

Step 2: Set up myTarget demand in Ad Manager UI

Configure mediation settings for your 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 under Inventory and Mobile application to which you want to add mediation.

Next, click the Add yield partner button.

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

Select myTarget as the Ad network, enter a unique Name and enable Mediation.

Turn on Automatic data collection, and enter the Permanent Access Token obtained in the previous section.

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 Slot ID obtained in the previous section. Then, enter a Default CPM value.

Click Save at the bottom of the page when done.

Add Mail.ru to GDPR and US state regulations ad partners list

Follow the steps in European regulations settings and US state regulations settings to add Mail.ru to the European and US state regulations ad partners list in the Ad Manager UI.

Step 3: Import the myTarget SDK and adapter

In your app-level gradle file, add the following implementation dependencies and configurations:

Kotlin

dependencies {
    implementation("com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.4.0")
    implementation("com.google.ads.mediation:mytarget:5.51.2.0")
}

configurations.configureEach {
    exclude(group = "com.google.android.gms", module = "play-services-ads")
    exclude(group = "com.google.android.gms", module = "play-services-ads-lite")
}

Groovy

dependencies {
    implementation 'com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.4.0'
    implementation 'com.google.ads.mediation:mytarget:5.51.2.0'
}

configurations.configureEach {
    exclude group: 'com.google.android.gms', module: 'play-services-ads'
    exclude group: 'com.google.android.gms', module: 'play-services-ads-lite'
}

Manual integration

Step 4: Implement privacy settings on myTarget SDK

To comply with the Google EU User Consent Policy, you must make certain disclosures to your users in the European Economic Area (EEA), the UK, and Switzerland, and obtain their consent for the use of cookies or other local storage where legally required, and for the collection, sharing, and use of personal data for ads personalization. This policy reflects the requirements of the EU ePrivacy Directive and the General Data Protection Regulation (GDPR). You are responsible for verifying that consent is propagated to each ad source in your mediation chain.

In SDK version 5.1.0, myTarget added a user consent API to support privacy requirements. The following sample code shows how to pass this consent information to the myTarget SDK. If you choose to call this method, it is recommended that you do so prior to requesting ads through GMA Next-Gen SDK.

Java

MyTargetPrivacy.setUserConsent(true);

Kotlin

MyTargetPrivacy.setUserConsent(true)

Additionally, if the user is known to be in an age-restricted category, you can use the following code to pass this consent information to the myTarget SDK.

Java

MyTargetPrivacy.setUserAgeRestricted(true);

Kotlin

MyTargetPrivacy.setUserAgeRestricted(true)