Advanced Matching

This document explains how to send your app events user data to Facebook for Advanced Matching. This information gets hashed before it is shared with us. We use the hashed information to more accurately determine which people took action in response to your ad. With this data, Facebook can match conversion events to your customers to optimize your ads and build larger re-marketing audiences.

After matching has taken place, Facebook promptly discards the hashed data.

You can set up Advanced Matching using one of the following methods:

  • The Facebook SDK – Add code to your Android or iOS mobile app to manually send data to Facebook.
  • The Facebook App Events API - Add queries to your code to manually send data to Facebook.
  • The Events Manager – Configure your app in the Events Manager dashboard to turn on Automatic Advanced Matching to send data to Facebook.
  • The Mobile Measurement Partners (MMP) SDK – Add code to your Android or iOS app to send data to your Adjust dashboard.

Use the Facebook SDK

When using the FB SDK to send user app events data to Facebook, all user data will be hashed. This hashed data persist between app instances.

Requirements

  • Facebook SDK 4.36 or later

Android

Set user data while initializing AppEventsLogger with the setUserData function. This function will hash the user data.

AppEventsLogger logger = AppEventsLogger.newLogger(MainActivity.this);
AppEventsLogger.setUserData(
  “jsmith@example.com”,     //email
  “john”,                   //first name
  “smith”,                  //last name
  “16505554444”,            //phone number
  “19910526”,               //birthdate
  “f”,                      //gender
  “menlopark”,              //city
  “ca”,                     //state
  “94025”,                  //zip code
  “us”                      //country
);

iOS

Set user data while initializing FBSDKAppEvents with the setUserData function. The user data will be hashed and will persist between app instances.

Recommendations

App Store Connect for iOS 14

Events that your app collects and sends to Facebook may require you to disclose these data types in the App Store Connect questionnaire. It is your responsibility to ensure this is reflected in your application’s privacy policy. Visit the Apple App Store Privacy Details article to learn more about the data types you will need to disclose.

Sample Code to Set One Data Type

[FBSDKAppEvents setUserData: @"jsmith@example.com" forType:FBSDKAppEventEmail];

Sample Code to Set Multiple Data Types

NSDictionary *const userData = @{
        @"em": @"jsmith@example.com",
        @"fn": @"john",
        @"ln": @"smith",
        @"ph": @"16505554444",
        @"db": @"19910526",
        @"ge": @"f",
        @"ct": @"menlopark",
        @"zp": @"94025",
        @"cn": @"us"};
[FBSDKAppEvents setUserEmail:(NSString *)userData["@em"]
     firstName:(NSString*)userData["@fn"]
     lastName:(NSString *)userData[@"ph"]
     phone:(NSString *)userData[@"ph"]
     dateOfBirth:(NSString *)userData[@"db"]
     gender:(NSString *)userData[@"ge"]
     city:(NSString *)userData[@"ct"]
     state:(NSString *)userData[@"st"]
     zip:(NSString *)userData[@"zp"]
     country:(NSString *)userData[@"cn"]];
User DataParameterFormatExample

Email

em

jsmith@example.com

First Name

fn

Lowercase letters

john

Last Name

ln

Lowercase letters

smith

Phone

ph

Digits only including country code and area code

16505554444

External ID

external_id

Any unique ID from the advertiser, such as loyalty membership ID, user ID, and external cookie ID.

a@example.com

Gender

ge

Single lowercase letter, f or m, if unknown, leave blank

f

Birthdate

db

Digits only with birth year, month, then day

19910526 for May 26, 1991.

City

ct

Lowercase with any spaces removed

menlopark

State or Province

st

Lowercase two-letter state or province code

ca

Zip or Postal Code

zp

Digits only

94025

Country

cn

Lowercase two-letter country code

us

Use the Events Manager

Automatic Advanced Matching automatically configures your Facebook SDK to detect and receive user data along with the event, or action, that took place in your app. This data is hashed before sending it to Facebook.

To turn on Automatic Advanced Matching, go to your Events Manager, select your app's Settings tab and toggle Automatic Advanced Matching to ON. You can also share hashed email addresses and phone numbers.

Note, you must have implemented the Facebook SDK 5.8.0 or later.

Use the Adjust SDK

Add Customer Data to Adjust Events

When using the Adjust Mobile Measurement Partners (MMP) SDK, please use the hash function as shown in the example below, as the MMP SDK won't hash it automatically. If you don't use a hash function our API will throw an exception and not accept plain text.

Add customer data parameters to be transmitted to network partners, which have been activated in your Adjust dashboard, by calling the addPartnerParameter method on your ADJEvent instance.

Note, you do not need to implement the Facebook SDK.

Android Example Code

AdjustEvent event = new AdjustEvent('abc123');
event.addPartnerParameter('em', 'sha256_hashed_email');
event.addPartnerParameter('ph', 'sha256_hashed_phone');
Adjust.trackEvent(event);

iOS Example Code

ADJEvent *event = [ADJEvent eventWithEventToken:@'abc123'];

[event addPartnerParameter:@'em' value:@'sha256_hashed_email'];
[event addPartnerParameter:@'ph' value:@'sha256_hashed_phone'];

[Adjust trackEvent:event];

For more information please visit the Github Code examples.

Map Adjust Parameters to Facebook Parameters

Use the following steps to map the Adjust parameter to the Facebook parameter in the Adjust dashboard.

  1. In your Adjust dashboard, click on the Settings of the app for which you wish to map the partner parameters.
  2. Select Partner Setup.
  3. Click on the partner of interest.
  4. Select Partner Parameter Mapping.
  5. Enter the partner parameter names as sent to Adjust by the SDK in the left FROM APP column. This should be the same for every partner. For example, if you are using email as parameter name in the Adjust SDK, then enter “email”.
  6. Enter the partner parameter names as desired by this partner in the right TO PARTNER column. This is partner specific. The parameter used in the Facebook SDK should be in format of ud[pii_type_name]. For example, "email" should use ud[em], phone should use ud[ph].

For more information, please visit the Adjust Documentation.