Targeting by Mobile Advertiser IDs

You can create ads targeting people by customer lists, and one way to make such a list is by using mobile advertiser IDs. A mobile advertiser ID is an Apple or Android Advertising Identifier or a Facebook App Scoped ID. This page explains how you can get these IDs and how you can use them when creating custom audiences for your app ads.

Before you start, please read Targeting by Customer Lists.

Overview: Accessing and Targeting User IDs

When to Access the App Scoped

Identify when you want to access app scoped IDs. For example, you can access the ID when your app launches or when the user takes a certain action, such as making an in-app purchase.

How to Identify a Person

There are several technologies you can use to identify a person:

  • Apple Advertising Identifier (IDFA)
  • Android Advertising ID
  • Facebook App Scoped ID

We give code examples for all of these techniques below.

Storing Data

After you collect the IDs, store them in a database of your choice, or in an Excel or .csv file.

Exporting Data

The Facebook Ads Manager requires you to provide your data as an Excel or .csv file. Most database systems can export to one of these formats.

Importing Data to Facebook Ads Manager

Follow our Targeting by Customer Lists guide. Use the Excel or .csv file when it is time to import the customer list.

Supported Mobile Advertiser IDs

We support three types of Mobile Advertiser IDs:

ID Description

Apple Advertising Identifier (IDFA)

An advertising ID that Apple provides as part of iOS in its ads framework.

Android Advertising ID

An advertsing ID that Google provides as part of Google Play services.

Facebook App Scoped ID

If people are logged in to your app via Facebook, you can use their App Scoped IDs for targeting.

Technical Implementation

Apple and Android Advertising Identifiers

// This call does NOT require the Facebook SDK for iOS
#import <AdSupport/ASIdentifierManager.h>
NSString *userId = [[[ASIdentifierManager sharedManager]
   advertisingIdentifier] UUIDString];
// Next: Store the user ID in your database
// This call does NOT require the Facebook SDK for Android!
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
Info adInfo = null;
try {
     adInfo = AdvertisingIdClient.getAdvertisingIdInfo(mContext);
} catch (IOException e) {
     // ...
} catch (GooglePlayServicesAvailabilityException e) {
     // ...
} catch (GooglePlayServicesNotAvailableException e) {
     // ...
} 
String userId = adInfo.getId();
// Next: Store the user ID in your database

Facebook App Scoped ID

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

- (void)viewDidLoad
{
  // Enable profile updates for example in `viewDidLoad`
  [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
} 

- (void)yourSelector
{
  // Once user is logged in via Facebook Login you can call:
  NSString *userId = [FBSDKProfile currentProfile].userID;
  // Next: Store the ID in your database      
}
// User needs to be logged in via Facebook Login
String userId = Profile.getCurrentProfile().getId();
// Next: Store the ID in your database