Share your feedback about the Google Mobile Ads SDK! Take the annual survey.

Integrating Facebook 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

  • Xcode 9.0 or higher
  • iOS Deployment target of 9.0 or higher
  • Google Mobile Ads SDK 7.46.0 or higher

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 have filled out the required information, you will 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, check the This app is using mediation box and click Submit.

You will 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. Take note of the Placement ID, which will be used when setting up your AdMob 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];
  // Log the adapter patch version to 3 digits to represent the x.x.x.x versioning
  // used by adapters.
  NSLog(@"Adapter version: %zd.%zd.%03zd",
        adapterVersion.majorVersion,
        adapterVersion.minorVersion,
        adapterVersion.patchVersion);
  NSLog(@"SDK version: %zd.%zd.%zd",
        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 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];

Ad rendering

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

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

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.

Send feedback about...

Need help? Visit our support page.