Integrating Facebook Audience Network with Open Bidding Mediation

This guide is intended for publishers who want to use the Google Mobile Ads SDK to load and display ads from the Facebook Audience Network via Open Bidding mediation. It covers how to add Facebook ads to an ad unit's mediation configuration and how to integrate the Facebook Audience Network SDK and adapter into an iOS app.

Supported ad formats and features

The AdMob mediation adapter for the Facebook Audience Network has the following capabilities:

Formats
Banners
Interstitials
Rewarded Video
Native Advanced
Features
Smart Banners
Native Video

Requirements

  • iOS deployment target of 9.0 or higher

  • The latest Facebook Audience Network SDK usually requires the latest version of Xcode

  • Latest Facebook iOS adapter

  • Latest Facebook Audience Network iOS SDK

  • Latest Google Mobile Ads SDK

Prerequisites

Follow the quick-start guide to download and install the Google Mobile Ads, add your app ID to your Info.plist file, and call startWithCompletionHandler:.

Step 1: Set up Facebook Audience Network

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

Click Create a new Business Manager account and fill out the required fields with your business details.

Once you've filled out the required information, you'll be prompted to create a property for your app. Enter the desired name of the property for your app and click Go to Monetization Manager.

Next, select iOS as the platform to monetize.

Indicate whether or not your app is live and click Submit.

You'll be prompted to create an ad placement for your application. Select a format, fill out the form and click Next.

The next step presents an overview of the placement you created. Check the This app is using mediation checkbox and take note of the Placement ID, which will be used when setting up your ad unit ID.

Step 2: Configure mediation settings for your AdMob ad unit

You need to add Facebook to the mediation configuration for your ad unit. First sign in to your AdMob account.

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 Facebook 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. 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 Facebook Audience Network as an ad source

In the Ad Sources card, select Add Ad Network. Select FaceBook (Open Bidding). Enter the Placement ID obtained in the previous section and click Done.

Finally, click Save.

Step 3: Import the Facebook Audience Network SDK and adapter

  • Add the following line to your project's Podfile:

    pod 'GoogleMobileAdsMediationFacebook'
    
  • From the command line run:

    pod install --repo-update

Manual integration

Verify your adapter and SDK versions

To log the adapter and SDK versions, use the following code snippet:

Class<GADMediationAdapter> adapterClass = NSClassFromString(@"GADMediationAdapterFacebook");
if (adapterClass != nil) {
  GADVersionNumber adapterVersion = [adapterClass version];
  GADVersionNumber sdkVersion = [adapterClass adSDKVersion];
  NSLog(@"Adapter version: %ld.%ld.%ld.%ld",
        adapterVersion.majorVersion,
        adapterVersion.minorVersion,
        adapterVersion.patchVersion / 100,
        adapterVersion.patchVersion % 100);
  NSLog(@"SDK version: %ld.%ld.%ld",
        sdkVersion.majorVersion,
        sdkVersion.minorVersion,
        sdkVersion.patchVersion);
}

Logging the adapter version in Swift is not possible since the dynamic runtime feature does not exist in Swift, making it infeasible to dynamically create the class from the class name. If this is needed in Swift, it needs to be written in Objective-C and imported using a bridging header.

Step 4: Additional Code Required

No Additional code required for Facebook Audience Network integration.

Optional Steps

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.

Please review Facebook's guidance for information about GDPR and Facebook advertising.

Using native ads

Some Facebook native ad assets do not map one to one to Google native ad assets. Such assets are passed back to the publisher in the extraAssets property of GADNativeAd. Here's a code example showing how to extract these assets:

Swift

let socialContext: String = unifiedNativeAd.extraAssets[GADFBSocialContext]

Objective-C

NSString *socialContext = unifiedNativeAd.extraAssets[GADFBSocialContext];

Using Facebook Native Ads without a MediaView

If your app renders native ads without a GADMediaView asset, Facebook Audience network requires that you implement their native banner ad format. The Facebook adapter version 5.7.1.1 and higher officially supports requesting of Native Banner ad formats for open-bidding.

Ad rendering

The Facebook adapter returns its native ads as UnifiedNativeAd objects. It populates the following unified native ads display fields for a GADUnifiedNativeAd.

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

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