With our Facebook Ads integration you can:
Accurately track subscriptions generated from Facebook Ad campaigns, allowing you to know precisely how much revenue your campaigns generate.
Send trial starts, trial conversions, and renewals directly from RevenueCat to Facebook Ads Manager, allowing for accurate tracking without an app open.
Continue to follow your cohorts for months to know the long tail revenue generated by your campaigns.
# 1. Install Facebook SDK
Before RevenueCat can integrate with Facebook, your app must be running the Facebook SDK. Refer to the [Facebook developer documentation](🔗) for the latest installation instructions.
# 2. Send device data to RevenueCat
The Facebook integration requires some device-specific data. RevenueCat will only send events into Facebook Ads Manager if the below [Subscriber Attributes](🔗) keys have been set for the device.
|`||iOS [advertising identifier](🔗) UUID||✅ (iOS only)|
|`||Google [advertising identifier](🔗)||✅ (Android only)|
|`||||✅ (iOS only)|
|`||Android [device identifier](🔗)||✅ (Android only)|
|`||iOS [vender identifier](🔗) UUID||❌ (optional)|
|`||The IP address of the device||❌ (optional)|
|`||The email address of the user||❌ (optional)|
|`||The phone number of the user||❌ (optional)|
These properties can be set manually, like any other [Subscriber Attributes](🔗), or through the helper methods to `
collectDeviceIdentifiers()` and `
Device identifiers with iOS App Tracking Transparency (iOS 14.5+)
If you are requesting the App Tracking permission through ATT to access the IDFA, you can call `
.collectDeviceIdentifiers()` _again_ if the customer accepts the permission to update the `
$idfa` attribute in RevenueCat.
You should make sure to set attributes after the _Purchases SDK_ is configured, and before the first purchase occurs. It's safe to set this multiple times, as only the new/updated values will be sent to RevenueCat.
Import AdSupport Framework (iOS)
The AdSupport framework is required to access the IDFA parameter on iOS. Don't forget to import this into your project.
Remove Facebook SDK Purchase Tracking
Make sure to remove all client side tracking of revenue. Since RevenueCat will be sending events for all revenue actions, tracking purchases with the Facebook SDK directly can lead to double counting of revenue in Facebook Ads Manager.
You can disable automatic In-App Purchase event logging from the Facebook SDK or from your Facebook app dashboard. Go to the iOS/Android card under Settings > Platform > Log In-App Events Automatically > No
To continue to track install and usage events in Facebook, follow the steps in the next section.
## Track Install and Usage Events
As noted above, you'll need to disable all client side tracking of revenue to prevent double counting of revenue in Facebook Ads Manager. To continue tracking install and usage events, you'll need to call Facebook's 'activate app' event after configuration:
You can see Facebook's App Events Reference [here](🔗).
# 3. Send RevenueCat events into Facebook Ads Manager
After you've set up the _Purchases SDK_ to send attribution data to RevenueCat, you can "turn on" the integration from the RevenueCat dashboard.
Navigate to your project in the RevenueCat dashboard and find the _Integrations_ card in the left menu. Select **+ New**
Choose **Facebook** from the Integrations menu.
Add your Facebook App ID for production events (and optionally an App ID for sandbox events).
Add the Facebook Client Token for your app (and for the sandbox App ID if included). You can find your Client Token in the Facebook dashboard under your **App > Settings > Advanced > Client Token**. You may need to click the 'Reset' button if there's no Client Token visible.
(Optional) You can toggle between different names for Facebook events.
Select whether you want sales reported as gross revenue (before app store commission), or after store commission and/or estimated taxes.
## Event Names
RevenueCat allows you to choose from different 'Standard' Facebook event names. Using 'Standard' events is recommended by Facebook for optimizing advertising campaigns and audiences.
|RevenueCat Event||Recommended Facebook Event|
# 4. Testing the Facebook Ads Manager integration
You can test the Facebook integration end-to-end before going live. It's recommended that you test the integration is working properly for new users, and any existing users that may update their app to a new version.
## Add a sandbox App Id and sandbox Client token in the RevenueCat dashboard
Before you test the integration, make sure you have a Facebook App Id and Client Token set in the "Sandbox" fields in RevenueCat. This is required if you want the integration to trigger for sandbox purchases.
## Make a sandbox purchase with a new user
Simulate a new user installing your app, and go through your app flow to complete a sandbox purchase.
## Check that the required device data is collected
Navigate the the [Customer View](🔗) for the test user that just made a purchase. Make sure that all of the required data from step 1 above is listed as attributes for the user.
## Check that the Facebook event delivered successfully
While still on the Customer View, click into the test purchase event in the [Customer History](🔗) and make sure that the Facebook integration event exists and was delivered successfully.
# 5. View Events in Facebook
Once events are delivered to Facebook, they can be used across Events Manager, Ads Manager, and Audiences.
Facebook event delay
Note that there could be up to a 24 hour delay from when events are sent to when they are shown in the Facebook Events Manager dashboard.
## Events Manager
The events sent from RevenueCat will appear throughout Facebook Events Manager as 'Standard' event types. Any events sent with revenue attached will be counted toward the 'Revenue' number in Facebook. This includes trial conversions and renewals that occur when the app isn't active.
## Advanced Matching
RevenueCat will send customer information that you specify as subscriber attributes to Facebook. This information includes email, name, phone number, etc. Make sure the Automatic Advanced Matching toggle is turned on under your app settings.
## Ads Manager
Within Facebook Ads Manager, you can customize the display columns to include subscription specific metrics. The 'Subscriptions' and 'Trials Started' values will be updated by the 'Subscribe' and 'StartTrial' events sent by RevenueCat, respectively.
By tracking the subscription revenue attributed to your Facebook campaigns you can quickly spot your most effective campaigns.
Facebook allows you to create custom audiences based off of events. This means you can create an audience of subscribers, and even create a "Lookalike" audience for better ad targeting.
To create a custom audience off of subscribers:
Create a Custom Audience and select 'App activity' as the source.
Choose an event, such as 'Subscribe' to create your audience off of.
You've done it!
You should start seeing events from RevenueCat appear in Facebook Ads Manager.