Integrate Meta Audience Network with bidding

This guide shows you how to use the Google Mobile Ads SDK to load and display ads from Meta Audience Network using 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 and adapter into a Flutter app.

Supported integrations and ad formats

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

Integration
Bidding
Waterfall  1
Formats
Banner
Interstitial
Rewarded
Rewarded Interstitial

1 Meta Audience Network became bidding only in 2021.

Requirements

  • Latest Google Mobile Ads SDK
  • Flutter 3.7.0 or higher
  • To deploy on Android
    • Android API level 21 or higher
  • To deploy on iOS
    • iOS deployment target of 10.0 or higher
    • The latest Meta Audience Network SDK usually requires the latest version of Xcode.
  • A working Flutter project configured with Google Mobile Ads SDK. See Get Started for details.
  • Complete the mediation Get started guide

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.

Android

iOS

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.

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 Ad Manager UI

Configure mediation settings for your ad unit

Android

For instructions, see step 2 in the guide for Android.

iOS

For instructions, see step 2 in the guide for iOS.

Add Facebook to GDPR and US state regulations ad partners list

Follow the steps in GDPR settings and US state regulations settings to add Facebook to the GDPR and US state regulations ad partners list in the Ad Manager UI.

Step 3: Import the Meta Audience Network SDK and adapter

Integration through pub.dev

Add the following dependency with the latest versions of the Meta Audience Network SDK and adapter in your package's pubspec.yaml file:

dependencies:
  gma_mediation_meta: ^1.0.0

Manual Integration

Download the latest version of Google Mobile Ads mediation plugin for Meta Audience Network, extract the downloaded file, and add the extracted plugin folder (and its contents) to your Flutter project. Then, reference the plugin in your pubspec.yaml file by adding the following dependency:

dependencies:
  gma_mediation_meta:
    path: path/to/local/package

Step 4: Implement privacy settings on Meta Audience Network 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.

Review Meta's guidance for information about GDPR and Meta advertising.

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.

For users in California, review Meta's data processing options.

Step 5: Add required code

Android

No additional code required for Meta Audience Network integration.

iOS

SKAdNetwork integration

Follow Meta Audience Network's documentation to add the SKAdNetwork identifiers to your project's Info.plist file.

Advertising tracking enabled

If you are building for iOS 14 or higher, check Meta Audience Network's instructions on how to set their Advertising Tracking Flag.

Step 6: Test your implementation

Enable test ads

Make sure you register your test device for Ad Manager 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

Caching on Android 9

Android

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.

iOS

Not applicable for iOS integrations.

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 under the following classes:

Android

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

iOS

GADMAdapterFacebook
GADMediationAdapterFacebook

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

Android

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.

iOS

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 Meta Audience Network ad object failed to initialize.
104 The Meta Audience Network SDK failed to present their interstitial/rewarded ad.
105 Root view controller of the banner ad is nil.
106 The Meta Audience Network SDK failed to initialize.
1000-9999 The Meta Audience Network returned an SDK-specific error. See Meta Audience Network's documentation for more details.

Meta Audience Network Flutter Mediation Adapter Changelog

1.1.0

  • Verified compatibility with Meta Android adapter version 6.17.0.0
  • Verified compatibility with Meta iOS adapter version 6.15.2.0
  • Built and tested with the Google Mobile Ads Flutter Plugin version 5.1.0.

1.0.1

  • Added dart class to allow correct compatibility analysis with host platforms
  • Verified compatibility with Meta Android adapter version 6.17.0.0
  • Verified compatibility with Meta iOS adapter version 6.15.0.0
  • Built and tested with the Google Mobile Ads Flutter Plugin version 5.1.0.

1.0.0

  • Initial release.
  • Verified compatibility with Meta Android adapter version 6.17.0.0
  • Verified compatibility with Meta iOS adapter version 6.15.0.0
  • Built and tested with the Google Mobile Ads Flutter Plugin version 5.0.0.