Pass Hashed Information for Facebook Advanced Matching
Overview
Facebook has a way for attribution providers and customers to send up hashed information about users to enhance how they do matching for attribution and analytics. With this data, Facebook can match conversion events to your customers to optimize your ads and build larger re-marketing audiences.
For more information, please see Facebook's document on Advanced Matching.
Fields Passed to Facebook
User Data | Parameter | Format | Example |
---|---|---|---|
| |||
First Name |
| Lowercase letters |
|
Last Name |
| Lowercase letters |
|
Phone |
| Digits only including country code and area code |
|
External ID |
| Any unique ID from the advertiser, such as loyalty membership ID, user ID, and external cookie ID. | |
Gender |
| Single lowercase letter, |
|
Birthdate |
| Digits only with birth year, month, then day |
|
City |
| Lowercase with any spaces removed |
|
State or Province |
| Lowercase two-letter state or province code |
|
Zip or Postal Code |
| Digits only |
|
Country |
| Lowercase two-letter country code |
|
Set Hashed Information for the SDK
Branch provides methods in our iOS and Android SDKs to set the hashed information to pass for Facebook Advanced Matching (set before initializing the SDK). Once set, this parameter is attached to install, open, and events until cleared or the app restarts.
...
//set hash parameters for Facebook Advanced Matching
Branch.getInstance().addFacebookPartnerParameter(withName: "em", value: "11234e56af071e9c79927651156bd7a10bca8ac34672aba121056e2698ee7088")
...
//initialize Branch session
Branch.getInstance().initSession(...)
Branch branch = Branch.getAutoInstance(getApplicationContext());
branch.addFacebookPartnerParameterWithName("em", "194b86d986ad041666822dad7602f1a7bac1d9e286273e86141666ffb4b1909b");
Logging Events
You can also set the value when logging events, you must pass in the hashed value of the parameter (user data) you want to pass.
Sample code to pass SHA256 hashed email and phone number:
let event = BranchEvent.standardEvent(.purchase)
event.partnerParameters = [
"em": "6e3913852f512d76acff15d1e402c7502a5bbe6101745a7120a2a4833ebd2350",
"ph": "05962a9b2bd6519d32a32e79a0273383b3edb717430fef5e8848821b5fc30c61"
]
event.logEvent()
new BranchEvent(BRANCH_STANDARD_EVENT.ADD_TO_CART)
.addPartnerParameter("em", "6e3913852f512d76acff15d1e402c7502a5bbe6101745a7120a2a4833ebd2350")
.addPartnerParameter("ph", "05962a9b2bd6519d32a32e79a0273383b3edb717430fef5e8848821b5fc30c61")
.logEvent(context);
Additional details on Branch event tracking can be found here.
Updated 12 months ago