Send your event data from RudderStack to Facebook App Events.
11 minute read
Facebook App Events is Facebook’s event tracking functionality which lets you track events via your app or web page, including user activities such as app installation, purchases, etc.
Find the open source transformer code for this destination in the GitHub repository.
Once you have confirmed that the source platform supports sending events to Facebook App Events, follow these steps:
From your RudderStack dashboard, add a source. Then, from the list of destinations, select Facebook App Events.
Assign a name to the destination and click Continue.
Connection settings
To successfully configure Facebook App Events as a destination, you will need to configure the following settings:
APP ID: Enter your Facebook App ID. See FAQ for more information on getting your Facebook App ID.
The following settings are applicable only if you are sending events to Facebook using device mode:
Limited Data Use: Enable this setting to send the end user’s country and state information. Facebook processes the user data according to the data regulations set for that region. See Limited Data Use for more information on this setting.
You can allow Facebook to detect your country and state automatically by choosing the Use Facebook to detect Automatically option.
Client-side Events Filtering: This setting lets you specify which events should be blocked or allowed to flow through to Facebook App Events. See Client-side Events Filtering for more information.
Consent management settings: Configure the consent management settings for the specified source by choosing the Consent management provider from the dropdown and entering the relevant consent category IDs. See Consent Management in RudderStack for more information on this feature.
Add device mode integration
Depending on your platform of integration, follow the below steps to integrate App Events with your app.
Send the user’s consent to App Events as shown below:
For Objective-C:
// Set AdvertiserTrackingEnabled to YES if a user provides consent
[FBSDKSettingssetAdvertiserTrackingEnabled:YES];// Set AdvertiserTrackingEnabled to NO if a user does not provide consent
[FBSDKSettingssetAdvertiserTrackingEnabled:NO];
For Swift:
// Set AdvertiserTrackingEnabled to true if a user provides consentSettings.setAdvertiserTrackingEnabled(true)// Set AdvertiserTrackingEnabled to false if a user does not provide consentSettings.setAdvertiserTrackingEnabled(false)
Configure your project by adding the following lines to(<dict>...</dict>) in yourInfo.plist :
Make sure you replacefbAPP-ID ,APP-ID,CLIENT-TOKEN,APP-NAME with the app-specific details from the Facebook for Developers platform.
After adding the dependency, register theRudderFacebookFactory with yourRudderClient initialization as afactory ofRudderConfig. To do this, run the following command to import theRudderFacebookFactory.h file in yourAppDelegate.m file:
Open the /app/res/values/strings.xml file and add the following lines. Make sure to replace APP_ID and CLIENT_TOKEN with the appropriate values:
<!-- Refer to the Facebook doc: https://developers.facebook.com/docs/android/getting-started--><stringname="facebook_app_id">APP_ID</string><stringname="facebook_client_token">CLIENT_TOKEN</string>
In the app/AndroidManifest.xml file, add a meta-data element to the application element. See the Facebook developer documentation for more details.
<!-- Refer to the Facebook doc: https://developers.facebook.com/docs/android/getting-started--><meta-dataandroid:name="com.facebook.sdk.ApplicationId"android:value="@string/facebook_app_id"/><meta-dataandroid:name="com.facebook.sdk.ClientToken"android:value="@string/facebook_client_token"/>
Configure React Native iOS app
Import the Facebook app into the AppDeletegate.swift file:
importFBSDKCoreKit
Initialize the Facebook App Events iOS SDK by adding the below snippet to the application method in AppDelegate.swift:
Configure the Info.plist file with the below XML snippet containing the data about your app. See the Facebook developer documentation for more details.
RudderStack logs the track call to Facebook using the logEvent method of the AppEventsLogger class. It uses the same eventName as you have passed in the track call along with all properties, after converting them into the accepted format.
A sample track call for an iOS application is as shown:.
[[RSClientsharedInstance]track:@"Accepted Terms of Service"properties:@{@"foo":@"bar",@"foo_int":@134}];
Whenrevenue andcurrency are present in the event properties of anytrack call, RudderStack makes aPurchase call to Facebook using itslogPurchase API along with the normaltrack call using thelogEvent API.
Ifcurrency is absent in the event properties, RudderStack sets the default value toUSD.
Supported mappings for iOS v2
This section lists some track event and property mappings which are applicable only when sending events via the iOS v2 device mode.
The following table lists the track event properties mappings between RudderStack and Facebook App Events:
RudderStack property
Facebook App Events property
product_id
ContentID
rating
MaxRatingValue
name
AdType
order_id
OrderID
currency
Currency
query
Query
description
Description
The following table lists the ecommerce events mappings between RudderStack and Facebook App Events:
RudderStack event
Facebook App Events event
Products Searched
Search
Products Viewed
View Content
Product Added
Add to Cart
Product Added To Wishlist
Add to Wishlist
Payment Info Entered
Add Payment Info
Checkout Started
Initiate Checkout
Order Completed
Purchase
Promotion Clicked
In-App Ad Click
Promotion Viewed
In-App Ad Impression
Product Reviewed
Rate
Spend Credits
Spent Credits
RudderStack also supports the following Lifecycle events and maps them as it is before sending them to Facebook App Events:
Complete Registration
Achieve Level
Complete Tutorial
Unlock Achievement
Subscribe
Start Trial
Page
The page method lets you record your website’s page views with any additional relevant information about the viewed page. You need not pass the event name as RudderStack automatically sets it to Viewed Page.
A sample page call using the RudderStack Android SDK is as shown:
rudderanalytics.page();
Thepage call is directly passed on to Facebook as atrack event via itslogEvent API, with the event name asViewed Page along with the the associated properties.
Screen
The screen call lets you record whenever your user views their mobile screen, with any additional relevant information about the screen.
A sample screen call using the RudderStack Android SDK is as shown:
In the above snippet, RudderStack captures the information related to the viewed screen, such as screen name and category.
The abovescreen call is directly passed on to Facebook as atrack event via itslogEvent API, with the event name asViewed {screen name} screen along with the the associated properties. The above example will be sent as atrack event with nameViewed Home screen along with its properties.
Limited Data Use
In July 2020, Facebook released a Limited Data Use feature to give businesses better control over how their data is used in their California Consumer Privacy Act (CCPA) compliance efforts.
Using this, you can send the Limited Data Use data processing parameters to Facebook for each event via RudderStack, so that Facebook can appropriately apply the user’s data choice.
To use this feature, enable the Limited Data Use setting in the RudderStack dashboard and control its behavior via the following data processing parameters:
Parameter
Default Value
Description
Data Processing Options State
0
Use Facebook’s geolocation to determine the end-user’s state.
Data Processing Options Country
0
Use Facebook’s geolocation to determine the end-user’s country.
In some cases, you can delay the collection of automatically logged events to obtain user consent or fulfill legal obligations instead of disabling it entirely. To do so, call thesetAutoLogAppEventsEnabled method of theFBSDKSettings class to re-enable auto-logging after the end-user provides the required consent.
In Objective-C:
[FBSDKSettingssetAutoLogAppEventsEnabled:YES];
In Swift:
FBSDKSettings.setAutoLogAppEventsEnabled(true)
To suspend event collection for any reason, set thesetAutoLogAppEventsEnabled method toNO for iOS orfalse for Swift:
In Objective-C:
[FBSDKSettingssetAutoLogAppEventsEnabled:NO];
In Swift:
FBSDKSettings.setAutoLogAppEventsEnabled(false)
To disable automatically logged events, add the following to yourAndroidManifest.xml file:
In some cases, you can delay the collection of automatically logged events to obtain user consent or fulfill legal obligations instead of disabling it entirely. To do so, call thesetAutoLogAppEventsEnabled() method of theFacebookSDK class and set it totrue . This re-enables event logging after the end-user has provided the required consent.
setAutoLogAppEventsEnabled(true);
To suspend event logging again for any reason, set thesetAutoLogAppEventsEnabled() method tofalse:
setAutoLogAppEventsEnabled(false);
Disable collection of advertiser IDs
To disable the collection of advertiser ID, open the application’s.plist as code in Xcode and add the following XML to the property dictionary:
In some cases, you can delay the collection ofadvertiser_id to obtain the user consent or fulfill any legal obligations instead of disabling it entirely. To do so, call thesetAdvertiserIDCollectionEnabled method of theFBSDKSettings class and set it toYES for iOS, ortrue for Swift after the end-user provides consent:
In some cases, you can delay the collection ofadvertiser_id to obtain user consent or fulfill any legal obligations instead of disabling it entirely. To do so, call thesetAdvertiserIDCollectionEnabled() method of theFacebookSDK class and set it totrue . This re-enables the collection ofadvertiser_id after the end-user provides the required consent:
setAdvertiserIDCollectionEnabled(true);
To suspend collection for any reason, set thesetAdvertiserIDCollectionEnabled() method tofalse:
setAdvertiserIDCollectionEnabled(false)
Disable automatic SDK initialization
To disable automatic SDK initialization in case of the Android SDK, add the following to yourAndroidManifest.xml file:
In some cases, you can delay the SDK initialization to obtain user consent or fulfill any legal obligations instead of disabling it entirely. To do so, call the class methodsetAutoInitEnabled and set it totrue to manually initialize the SDK after the end-user provides the required consent.
Starting from iOS version 14.5, you need to get the device consent to share data with Facebook by setting the isAdvertiserTrackingEnabled property. Refer to Facebook’s Get device consent documentation for more information.
FAQ
Where do I get the Facebook App ID?
You can find the Facebook App ID by logging into your Facebook Developer account, and navigating to the Home page of your application’s dashboard:
Where do I get the Facebook Client Token?
You can find the Facebook Client Token by logging into your Facebook Developer account and navigating to Settings > Advanced > Security section in the application’s dashboard:
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.