Integrate Meta Audience Network with bidding

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

Supported integrations and ad formats

The mediation adapter for Meta Audience Network has the following capabilities:

Integration
Bidding
Waterfall  1
Formats
Banner 2
Interstitial
Rewarded
Rewarded Interstitial
Native

1 Meta Audience Network became bidding only in 2021.
2 Meta Audience Network doesn't support anchored and inline adaptive banners.

Requirements

  • Android API level 24 or higher

Step 1: Set up configurations in Meta Audience Network UI

Sign up and log in to the Business Manager Start page.

Click Get started then Create new account.

Fill out the required fields with your business details and click Next.

Create a property

After you've filled out the required information, you're prompted to create a property for your app. Enter the desired name of the property for your app and click Next.

Next, select your platform to monetize.

Add your app details and click Next.

Set up your payment account by clicking Add a new payment account. You will be redirected to a new page to enter your payment information. Fill out the necessary details, then click Next.

Select Google AdMob as the Mediation platform, then click Create placement.

Select a format, fill out the form and click Create.

Take note of the Placement ID.

Click Done.

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, set up an app-ads.txt file for your app.

To implement app-ads.txt for Meta Audience Network, see Identifying Authorized Sellers with app-ads.txt.

Turn on test mode

See the Testing Audience Network Implementation guide for detailed instructions on how to enable Meta Audience Network test ads.

Step 2: Set up Meta Audience Network demand in AdMob UI

Configure mediation settings for your ad unit

You need to add Meta Audience Network 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 Meta Audience Network 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, and 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:

Add Meta Audience Network as an ad source


Under the Bidding card in the Ad Sources section, select Add ad source. Then select Meta Audience Network .

Click How to sign a partnership agreement and set up a bidding partnership with Meta Audience Network.



Click Acknowledge & agree, then click Continue.



If you already have a mapping for Meta Audience Network, you can select it. Otherwise, click Add mapping.



Next, enter the Placement ID obtained in the previous section. Then click Done.

Add Meta to GDPR and US state regulations ad partners list

Follow the steps in European regulations settings and US state regulations settings to add Meta to the European and US state regulations ad partners list in the AdMob UI.

Step 3: Import the Meta Audience Network 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:0.24.0-beta02")
    implementation("com.google.ads.mediation:facebook:6.21.0.1")
}

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:0.24.0-beta02'
    implementation 'com.google.ads.mediation:facebook:6.21.0.1'
}

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 Meta Audience Network SDK

To comply with 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 consent is propagated to each ad source in your mediation chain. Google is unable to pass the user's consent choice to such networks automatically.

Meta isn't registered on the IAB Europe Global Vendor List (GVL). Instead, you must use the Additional Consent technical specification. For more details, see Components of the Additional Consent. The Additional Consent specification works in conjunction with IAB Europe Transparency & Consent Framework (TCF) version 2. This specification lets you, along with their Consent Management Platforms (CMPs) and partners, collect and transmit supplementary consent signals for companies listed on the Google Ad Tech Providers (ATP) list, but are not yet part of the IAB Europe GVL.

Follow the guidance in Meta's documentation for GDPR and Meta advertising.

US states privacy laws

US 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 through a prominent "Do Not Sell My Personal Information" link on the "selling" party's homepage. The US 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.

Follow the guidance in Meta's documentation for data processing options for users in California.

Step 5: Add required code

No additional code is required for Meta Audience Network integration.

Step 6: Test your implementation

Enable test ads

Make sure you register your test device for AdMob and enable test mode in Meta Audience Network UI.

Verify test ads

To verify that you are receiving test ads from Meta Audience Network, enable single ad source testing in ad inspector using the Meta Audience Network (Bidding) ad source(s).

Optional steps

Native ads

Some Meta Audience Network native ad assets don't map one-to-one to Google native ad assets. Such assets are passed back to the publisher in a bundle through the getExtras() method in NativeAd. The adapter supports passing the following assets:

Request parameters and values
FacebookMediationAdapter.KEY_ID String. A unique ID of the native ad
FacebookMediationAdapter.KEY_SOCIAL_CONTEXT_ASSET String. The ad social context

Here's a code example showing how to extract these assets:

Example:

Kotlin

val extras = nativeAd.getExtras()
if (extras.containsKey(FacebookMediationAdapter.KEY_SOCIAL_CONTEXT_ASSET)) {
  var socialContext = extras.getString(FacebookMediationAdapter.KEY_SOCIAL_CONTEXT_ASSET)
  // ...
}

Java

Bundle extras = nativeAd.getExtras();
if (extras.containsKey(FacebookMediationAdapter.KEY_SOCIAL_CONTEXT_ASSET)) {
    String socialContext = extras.getString(FacebookMediationAdapter.KEY_SOCIAL_CONTEXT_ASSET);
    // ...
}

Using Meta Audience Network native ads without a MediaView

Meta Audience Network's native ad format requires rendering the MediaView asset. If you plan to render native ads without that asset, make sure to use Meta Audience Network's native banner ad format.

To use Meta Audience Network's native banner ads instead, you must select the Native Banner format when setting up Meta Audience Network and the adapter will automatically load the corresponding native ad format.

Ad rendering

The Audience Network adapter returns its native ads as NativeAd objects. It populates the following Native ads field descriptions for a NativeAd.

Field Populated by Meta Audience Network adapter
Headline
Image 1
Body
App icon
Call to action
Advertiser Name
Star rating
Store
Price

1 The Meta Audience Network adapter does not provide direct access to the main image asset for its native ads. Instead, the adapter populates the MediaView with a video or an image.

Impression and click tracking

The following table highlights when native ad impressions and clicks are recorded by GMA Next-Gen SDK.

Impression recording Click recording
1px of Meta Audience Network native ad asset on screen + asset rendering requirements Meta Audience Network SDK callback

Meta Audience Network has specific asset rendering requirements in order for an impression to be considered valid, depending on whether you selected the Native or Native Banner format when setting up Meta Audience Network.

Meta Audience Network native format Required asset Required rendering class
Native Media View MediaView
Native Banner App icon ImageView

Caching on Android 9

Starting with Android 9 (API level 28), cleartext support is disabled by default, which will affect the functionality of media caching of the Meta Audience Network SDK and could affect user experience and ads revenue. Follow Meta's documentation to update the network security configuration in your app.

Error codes

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

com.google.ads.mediation.facebook.FacebookAdapter
com.google.ads.mediation.facebook.FacebookMediationAdapter

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

Error code Reason
101 Invalid server parameters (e.g. missing Placement ID).
102 The requested ad size does not match a Meta Audience Network supported banner size.
103 The publisher must request ads with an Activity context.
104 The Meta Audience Network SDK failed to initialize.
105 The publisher did not request for Unified native ads.
106 The native ad loaded is a different object than the one expected.
107 The Context object used is invalid.
108 The loaded ad is missing the required native ad assets.
109 Failed to create a native ad from the bid payload.
110 The Meta Audience Network SDK failed to present their interstitial/rewarded ad.
111 Exception thrown when creating a Meta Audience Network AdView object.
1000-9999 The Meta Audience Network returned an SDK-specific error. See Meta Audience Network's documentation for more details.