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.
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.
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
The IP address of the device
The email address of the user
The phone number of the user
These properties can be set manually, like any other Subscriber Attributes, or through the helper methods to
import AdSupport // ... Purchases.configure(withAPIKey: "public_sdk_key") // ... // Automatically collect the $idfa, $idfv, and $ip values Purchases.shared.collectDeviceIdentifiers() // REQUIRED: Set the Facebook anonymous Id Purchases.shared.setFBAnonymousID(FBSDKCoreKit.AppEvents.anonymousID) // Optionally set additional user data Purchases.shared.setEmail("[email protected]") Purchases.shared.setPhoneNumber("+16505551234")
//.. Purchases.configure(this, "public_sdk_key") //.. // Automatically collect the $gpsAdId, $androidId, and $ip values Purchases.sharedInstance.collectDeviceIdentifiers() // Optionally set additional user data Purchases.sharedInstance.setEmail("[email protected]") Purchases.sharedInstance.setPhoneNumber("+16505551234")
import FBSDK from "react-native-fbsdk" //... Purchases.setDebugLogsEnabled(true); Purchases.setup("public_sdk_key"); //... // Automatically collect the $idfa, $idfv, and $ip values Purchases.collectDeviceIdentifiers(); // REQUIRED: Set the Facebook anonymous Id const anonymousId = await FBSDK.AppEventsLogger.getAnonymousID(); Purchases.setFBAnonymousID(anonymousId); // Optionally set additional user data Purchases.setEmail("[email protected]"); Purchases.setPhoneNumber("+16505551234");
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, call the Facebook SDK activateApp method after configuration.
After you've set up the Purchase SDK to send attribution data to RevenueCat, you can "turn on" the integration from the RevenueCat dashboard.
- Navigate to your app in the RevenueCat dashboard and 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.
- Select whether you want RevenueCat to report proceeds (after app store cut) or revenue (gross sales).
RevenueCat allows you to choose from different 'Standard' Facebook event names. Using 'Standard' events is recommended by Facebook for optimizing advertising campaigns and audiences.
Recommended Facebook Event
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.
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.
Simulate a new user installing your app, and go through your app flow to complete a sandbox purchase.
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.
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.
Once events are delivered to Facebook, they can be used across Analytics, 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 Analytics dashboard.
The events sent from RevenueCat will appear throughout Facebook Analytics 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.
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.
Updated about a month ago