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 User 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: Collecting and Targeting User IDs

When to Collect the User ID

Identify when you want to collect user IDs. For example, you can collect the user 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 User ID

We give code examples for all of these techniques below.

Storing Data

After you collect user 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 guide Targeting by Customer Lists. Use the Excel or .csv file when it is time to import the customer list.

Targeting by Customer Lists

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 User ID

If people are logged in to your app via Facebook, you can use their Facebook User 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 User 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 user ID in your database      
}
// User needs to be logged in via Facebook Login
String userId = Profile.getCurrentProfile().getId();
// Next: Store the user ID in your database