LogoLogo
  • Contributing to RudderStack
  • Destination_Name
  • LICENSE
  • RudderStack Docs
  • docs
    • FAQ
    • Identity Resolution
    • Home
    • cloud-extract-sources
      • ActiveCampaign Source
      • Bing Ads
      • Chargebee
      • Common Settings
      • Facebook Ads
      • Freshdesk
      • Google Ads Source
      • Google Analytics
      • Google Search Console
      • Google Sheets
      • Cloud Extract Sources
      • Intercom v2
      • Intercom
      • Mailchimp
      • Marketo
      • Mixpanel
      • NetSuite
      • Pipedrive
      • QuickBooks
      • Salesforce Pardot
      • Sendgrid Source
      • Stripe Source
      • Xero
      • Zendesk Chat
      • Zendesk
      • hubspot
        • HubSpot Data Model and Schema Information
        • HubSpot
      • salesforce
        • Salesforce
        • Schema Comparison: RudderStack vs. Segment
    • connections
      • Connection Modes: Cloud Mode vs. Device Mode
    • data-governance
      • Data Governance
      • RudderTyper
      • Data Governance API
      • RudderTyper
      • tracking-plans
        • Tracking Plans
        • Tracking Plan Spreadsheet
    • data-warehouse-integrations
      • Amazon Redshift
      • Azure Data Lake
      • Azure Synapse
      • ClickHouse
      • Databricks Delta Lake
      • Google Cloud Storage Data Lake
      • Google BigQuery
      • Identity Resolution
      • Warehouse Destinations
      • Microsoft SQL Server
      • PostgreSQL
      • Amazon S3 Data Lake
      • Snowflake
      • FAQ
      • Warehouse Schema
    • destinations
      • Destinations
      • Webhooks
      • advertising
        • Bing Ads
        • Criteo
        • DCM Floodlight
        • Facebook App Events
        • Facebook Custom Audience
        • Facebook Pixel
        • Google Ads (gtag.js)
        • Google AdWords Enhanced Conversions
        • Google Adwords Remarketing Lists (Customer Match)
        • Advertising
        • LinkedIn Insight Tag
        • Lotame
        • Pinterest Tag
        • Reddit Pixel
        • Snap Pixel
        • TikTok Ads
      • analytics
        • Amplitude
        • AWS Personalize
        • Chartbeat
        • Firebase
        • FullStory
        • Google Analytics 360
        • Google Analytics
        • Heap.io
        • Hotjar
        • Analytics
        • Indicative
        • Keen
        • Kissmetrics
        • Kubit
        • Lytics
        • Mixpanel
        • Pendo
        • PostHog
        • Quantum Metric
        • Singular
        • adobe-analytics
          • Adobe Analytics Heartbeat Measurement
          • Mobile Device Mode Settings
          • Web Device Mode Settings
          • E-commerce Events
          • Adobe Analytics
          • Setting Up Adobe Analytics in RudderStack
        • google-analytics-4
          • Cloud Mode
          • Device Mode
          • Google Analytics 4
          • Setting up Google Analytics 4
        • profitwell
          • ProfitWell
          • Cloud Mode
          • Device Mode
      • attribution
        • Adjust
        • AppsFlyer
        • Branch
        • Attribution
        • Kochava
        • TVSquared
      • business-messaging
        • Business Messaging
        • Intercom
        • Kustomer
        • Slack
        • Trengo
      • continuous-integration
        • Visual Studio App Center
        • Continuous Integration
      • crm
        • Delighted
        • HubSpot
        • CRM
        • Salesforce
        • Variance
        • Zendesk
      • customer-data-platform
        • Customer Data Platform
        • Segment
      • error-reporting
        • Bugsnag
        • Error Reporting
        • Sentry
      • marketing
        • ActiveCampaign
        • AdRoll
        • Airship
        • Appcues
        • Autopilot
        • Blueshift
        • Braze
        • CleverTap
        • Customer.io
        • Gainsight PX
        • Gainsight
        • Marketing
        • Iterable
        • Klaviyo
        • Leanplum
        • Mailchimp
        • Marketo Lead Import
        • Marketo
        • MoEngage
        • Ometria
        • Pardot
        • Post Affiliate Pro
        • Qualtrics
        • SendGrid
        • Salesforce Marketing Cloud
        • Userlist
        • drip
          • Cloud Mode
          • Device Mode
          • Drip
          • Setting Up Drip in RudderStack
      • productivity
        • Google Sheets
        • Productivity
      • storage-platforms
        • Amazon S3
        • DigitalOcean Spaces
        • Google Cloud Storage
        • Storage Platforms
        • Azure Blob Storage
        • MinIO
        • Redis
      • streaming-platforms
        • Amazon EventBridge
        • Amazon Kinesis Firehose
        • Amazon Kinesis
        • Azure Event Hubs
        • BigQuery Stream
        • Confluent Cloud
        • Google Pub/Sub
        • Streaming Platforms
        • Apache Kafka
      • tag-managers
        • Google Tag Manager
        • Tag Managers
      • testing-and-personalization
        • Algolia Insights
        • Candu
        • Google Optimize
        • A/B Testing & Personalization
        • LaunchDarkly
        • Monetate
        • Optimizely Full Stack
        • Optimizely Web
        • Split.io
        • Statsig
        • VWO (Visual Website Optimizer)
    • get-started
      • RudderStack Cloud vs. RudderStack Open Source
      • Glossary
      • Get Started
      • RudderStack Architecture
    • reverse-etl
      • Amazon Redshift
      • Amazon S3
      • ClickHouse
      • FAQ
      • Google BigQuery
      • Reverse ETL
      • PostgreSQL
      • Snowflake
      • common-settings
        • Importing Data using Models
        • Importing Data using Tables
        • Common Settings
        • Sync Modes
        • Sync Schedule
      • features
        • Airflow Provider
        • Features
        • Models
        • Visual Data Mapper
    • rudderstack-api
      • Data Regulation API
      • HTTP API
      • RudderStack API
      • Personal Access Tokens
      • Pixel API
      • Test API
      • api-specification
        • Application Lifecycle Events Specification
        • API Specification
        • Video Events Specification
        • rudderstack-ecommerce-events-specification
          • Browsing
          • Coupons
          • E-Commerce Events Specification
          • Ordering
          • Promotions
          • Reviewing
          • Sharing
          • Wishlist
        • rudderstack-spec
          • Alias
          • Common Fields
          • Group
          • Identify
          • RudderStack Event Specification
          • Page
          • Screen
          • Track
    • rudderstack-cloud
      • Audit Logs
      • Dashboard Overview
      • Destinations
      • RudderStack Cloud
      • Live Events
      • Connection Modes: Cloud Mode vs. Device Mode
      • Sources
      • Teammates (User Management)
      • connections
        • Adding a Destination
        • Connections
    • rudderstack-open-source
      • Control Plane Setup
      • RudderStack Open Source
      • installing-and-setting-up-rudderstack
        • Developer Machine Setup
        • Docker
        • Data Plane Setup
        • Kubernetes
        • Sending Test Events
    • stream-sources
      • App Center
      • AppsFlyer
      • Auth0
      • Braze
      • Customer.io
      • Extole
      • Event Stream Sources
      • Iterable
      • Looker
      • PostHog
      • Segment
      • Shopify
      • Webhook Source
      • rudderstack-sdk-integration-guides
        • Client-side Event Filtering
        • SDKs
        • AMP Analytics
        • Cordova
        • .NET
        • Go
        • Java
        • Node.js
        • PHP
        • Python
        • React Native
        • Ruby
        • Rust
        • Unity
        • SDK FAQs
        • rudderstack-android-sdk
          • Adding Application Class
          • Flushing Events Periodically
          • Android
        • rudderstack-flutter-sdk
          • Flutter SDK v1
          • Flutter v2
          • Flutter
        • rudderstack-ios-sdk
          • iOS
          • tvOS
          • watchOS
        • rudderstack-javascript-sdk
          • Data Storage in Cookies
          • Detecting Ad-blocked Pages
          • JavaScript
          • JavaScript SDK Enhancements
          • JavaScript SDK FAQs
          • Querystring API
          • Quick Start Guide
          • Version Migration Guide
          • consent-managers
            • Consent Managers
            • OneTrust
    • transformations
      • Access Token
      • FAQ
      • Transformations
      • Transformations API
    • user-guides
      • User Guides
      • administrators-guide
        • Troubleshooting Guide
        • Alerting Guide
        • Bucket Configuration Settings for Event Backups
        • Configuration Parameters
        • Event Replay
        • High Availability
        • Horizontal Scaling
        • Administrator's Guides
        • Infrastructure Provisioning
        • Monitoring and Metrics
        • Okta SSO Setup
        • OneLogin SSO Setup
        • RudderStack Grafana Dashboard
        • Software Releases
      • how-to-guides
        • How to Use Custom Domains
        • How to Develop Integrations for RudderStack
        • How to Configure a Destination via the Event Payload
        • How to Filter Events using Different Methods
        • How to Filter Selective Destinations
        • How to Submit a Pull Request for a New Integration
        • How-to Guides
        • How to Debug Live Destination Events
        • How to Use AWS Lambda Functions with RudderStack
        • create-a-new-destination-transformer-for-rudder
          • Best Practices for Coding Transformation Functions in JavaScript
          • How to Create a New Destination Transformation for RudderStack
        • implement-native-js-sdk-integration
          • How to Add a Device Mode SDK to RudderStack JavaScript SDK
          • How to Implement a Native JavaScript SDK Integration
        • rudderstack-jamstack-integration
          • How to Integrate RudderStack with Your JAMstack Site
          • How to Integrate Rudderstack with Your Angular App
          • How to Integrate Rudderstack with Your Astro Site
          • How to Integrate Rudderstack with Your Eleventy Site
          • How to Integrate Rudderstack with Your Ember.js App
          • How to Integrate Rudderstack with a Gatsby Website
          • How to Integrate Rudderstack with a Hugo Site
          • How to Integrate Rudderstack with Your Jekyll Site
          • How to Integrate Rudderstack with Your Next.js App
          • How to Integrate Rudderstack with Your Nuxt.js App
          • How to Integrate Rudderstack with Your Svelte App
          • How to Integrate Rudderstack with Your Vue App
      • migration-guides
        • Migrating from Blendo to RudderStack
        • Migrating Your Warehouse Destination from Segment to RudderStack
        • Migration Guides
        • Migrating from Segment to RudderStack
  • src
    • @rocketseat
      • gatsby-theme-docs
        • text
          • Home
Powered by GitBook
On this page
  • Getting Started
  • Connection settings
  • Adding Facebook App Events to Your Project
  • Identify
  • Track
  • Page
  • Screen
  • Limited Data Use
  • Configuring Facebook App Events SDK Based on User Consent
  • Disable Automatically Logged Events
  • Disable Collection of Advertiser IDs
  • Disable Automatic SDK Initialization
  • FAQs
  • Where do I get the Facebook App ID?
  • Where do I get the Facebook Client Token?
  • Contact Us

Was this helpful?

  1. docs
  2. destinations
  3. advertising

Facebook App Events

Step-by-step guide to send your event data from RudderStack to Facebook App Events.

PreviousDCM FloodlightNextFacebook Custom Audience

Last updated 3 years ago

Was this helpful?

is Facebook's event tracking functionality. It lets you track events via your app or web page, including user activities such as app installation, purchases, etc. This information is sent to Facebook for analytics and ad targeting, optimization, and measurement.

RudderStack supports Facebook App Events as a destination to which you can send your event data seamlessly.

Find the open-source transformer code for this destination in our .

Getting Started

To enable sending data to Facebook App Events, you will first need to add it as a destination in RudderStack. Once the destination is configured and enabled, events from RudderStack will start flowing to App Events.

Before configuring App Events as a destination, verify if Facebook supports the source platform by referring to the table below:

Connection Mode

Web

Mobile

Server

Device mode

-

Supported

-

Cloud mode

Supported

Supported

-

To know more about the difference between Cloud mode and Device mode in RudderStack, read the guide.

Once you have confirmed that the source supports sending events to Facebook App Events, follow these steps:

  • From your , add the source. From the list of destinations, select Facebook App Events.

  • Assign a name to the destination and click on Next. You should then see the following screen:

Connection settings

The connection settings required to configure App Events as a destination in RudderStack are listed below:

  • Enter the Facebook App ID.

The following options are applicable if you are using the Device mode to send your events to Facebook:

  • Limited Data Use: If this option is enabled, you can send the country and state of the end-user so that Facebook processes the user data according to the data regulations set for that region.

  • Click on Next to complete the configuration.

That's it! Facebook App Events should now be added and enabled as a destination in RudderStack.

Adding Facebook App Events to Your Project

Depending on your platform of integration, follow these steps below to add App Events to your project:

iOS Android To add Facebook to your iOS project:

  • pod 'Rudder-Facebook'
  • Initialize the Facebook App Events iOS SDK just before intializing the RudderStack iOS SDK as shown:

    [[FBSDKApplicationDelegate sharedInstance] application:application
                                 didFinishLaunchingWithOptions:launchOptions];
  • Send the user's consent to App Events as shown below:

    • For Objective-C:

      // Set AdvertiserTrackingEnabled to YES if a user provides consent
      [FBSDKSettings setAdvertiserTrackingEnabled:YES];
      // Set AdvertiserTrackingEnabled to NO if a user does not provide consent
      [FBSDKSettings setAdvertiserTrackingEnabled:NO];
    • For Swift:

      // Set AdvertiserTrackingEnabled to true if a user provides consent
      Settings.setAdvertiserTrackingEnabled(true)
      // Set AdvertiserTrackingEnabled to false if a user does not provide consent
      Settings.setAdvertiserTrackingEnabled(false)
  • Configure your project by adding the following lines to (...) in your Info.plist :

    <key>CFBundleURLTypes</key>
    <array>
      <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fbAPP-ID</string>
      </array>
      </dict>
    </array>
    <key>FacebookAppID</key>
    <string>APP-ID</string>
    <key>FacebookClientToken</key>
    <string>CLIENT-TOKEN</string>
    <key>FacebookDisplayName</key>
    <string>APP-NAME</string>
  • After adding the dependency, register the RudderFacebookFactory with your RudderClient initialization as a factory of RudderConfig. To do this, run the following command to import the RudderFacebookFactory.h file in your AppDelegate.m file:

    #import <Rudder-Facebook/RudderFacebookFactory.h>
  • Then, add the RudderStack iOS SDK initialization as shown:

    RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
    [builder withDataPlaneUrl:DATA_PLANE_URL];
    [builder withFactory:[RudderFacebookFactory instance]];
    [RSClient getInstance:WRITE_KEY config:[builder build]];

To add Facebook App Events to your Android project, follow these steps:

  • Add the repository, as shown:

    repositories {
        mavenCentral()
    }
  • Add the following lines to your app/build.gradle file under the dependencies section, as shown:

    implementation 'com.rudderstack.android.sdk:core:1.+'
    implementation 'com.rudderstack.android.integration:facebook:1.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:11.1.0'
  • Open your /app/res/values/strings.xml file and add the following lines. **Remember to replace [APP_ID] with your actual app ID**.

    <string name="facebook_app_id">[APP_ID]</string>
    <string name="fb_login_protocol_scheme">fb[APP_ID]</string>
  • In the app/manifests/AndroidManifest.xmlfile, add a meta-data element to the application element as shown: {/*

    <application android:label="@string/app_name" ...>
      ...
      <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
      ...
    </application>

    */}

  • Finally, change the initialization of your RudderClient in your Application class, as shown:

    val rudderClient = RudderClient.getInstance(
        this,
        WRITE_KEY,
        RudderConfig.Builder()
            .withDataPlaneUrl(DATA_PLANE_URL)
            .withFactory(FacebookIntegrationFactory.FACTORY)
            .build()
    )

Identify

For App Events, RudderStack supports the identify calls only in the mobile device mode.

The identify call from RudderStack sets the userId through the setUserID method from AppEventsLogger.

RudderStack sets the following properties (if available) using the setUserData method.

  • email

  • firstName

  • lastName

  • phone

  • birthday

  • gender

  • city

  • state

  • zip

  • country

A sample identify call for an iOS application is shown below:

[[RSClient sharedInstance] identify:@"developer_user_id"
                                 traits:@{@"email": @"bar@foo.com"}];

Track

The track call from RudderStack is logged to Facebook using the logEvent method of the AppEventsLogger class. RudderStack uses the same eventName as you have passed to the track method. Along with that, it will pass all the properties after converting them into an accepted format.

A sample track call for an iOS application is as shown:.

[[RSClient sharedInstance] track:@"Accepted Terms of Service"
                      properties:@{
                          @"foo": @"bar",
                          @"foo_int": @134
                      }];

When revenue and currency are present in the event properties of any track call, RudderStack makes a Purchase call to Facebook using its logPurchase API along with the normal track call using the logEvent API.

If currency is absent in the event properties RudderStack sets the default value to USD.

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();

The page call is directly passed on to Facebook as a track event via its logEvent API, with the event name as Viewed Page along with the the associated properties.

Screen

The screen method lets you record your users' screen views on their devices, along with any associated properties. This call is similar to the page call, but is exclusive to your mobile device.

A sample screen call using the RudderStack Android SDK is as shown:

[[RSClient sharedInstance] screen:@"Home" properties:@{
    @"category" : @"launcher"
}];

In the above snippet, RudderStack captures the information related to the viewed screen, such as screen name and category.

The above screen call is directly passed on to Facebook as a track event via its logEvent API, with the event name as Viewed {screen name} screen along with the the associated properties. The above example will be sent as a track event with name Viewed Home screen along with its properties.

Limited Data Use

You can now 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, simply enable the Limited Data Use setting on 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.

Configuring Facebook App Events SDK Based on User Consent

This section highlights the different consent-based options for configuring the App Events SDK.

Disable Automatically Logged Events

iOS Android

  • To disable automatic event logging, open the application's .plist as code in Xcode and add the following XML to the property dictionary:

    <key>FacebookAutoLogAppEventsEnabled</key>
    <false/>
  • 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 the setAutoLogAppEventsEnabled method of the FBSDKSettings class to re-enable auto-logging after the end-user provides the required consent.

    • In Objective-C:

      [FBSDKSettings setAutoLogAppEventsEnabled:YES];
    • In Swift:

      FBSDKSettings.setAutoLogAppEventsEnabled(true)
  • To suspend event collection for any reason, set the setAutoLogAppEventsEnabled method to NO for iOS or false for Swift, as shown:

    • In Objective-C:

      [FBSDKSettings setAutoLogAppEventsEnabled:NO];
    • In Swift:

      FBSDKSettings.setAutoLogAppEventsEnabled(false)
  • To disable automatically logged events, add the following to your AndroidManifest.xml file: {/*

    <application>
      ...
      <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
               android:value="false"/>
      ...
    </application>

    */}

  • 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 the setAutoLogAppEventsEnabled() method of the FacebookSDK class and set it to true . 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 the setAutoLogAppEventsEnabled() method to false, as shown:

    setAutoLogAppEventsEnabled(false);

Disable Collection of Advertiser IDs

iOS Android

  • 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:

    <key>FacebookAdvertiserIDCollectionEnabled</key>
    <false/>
  • In some cases, you can delay the collection of advertiser_id to obtain the user consent or fulfill any legal obligations instead of disabling it entirely. To do so, call the setAdvertiserIDCollectionEnabled method of the FBSDKSettings class and set it to YES for iOS, or true for Swift after the end-user provides consent, as shown:

    • In Objective-C:

      [FBSDKSettings setAdvertiserIDCollectionEnabled:@YES];
    • In Swift:

      FBSDKSettings.setAdvertiserIDCollectionEnabled(true);
  • To suspend collection for any reason, set the setAdvertiserIDCollectionEnabled method to NO for iOS or false for Swift.

    • In Objective-C:

      [FBSDKSettings setAdvertiserIDCollectionEnabled:@NO];
    • In Swift:

      FBSDKSettings.setAdvertiserIDCollectionEnabled(false)
  • To disable collection of advertiser-id, add the following code to your AndroidManifest.xml file:

    <application>
      ...
      <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled"
               android:value="false"/>
      ...
    </application>
  • In some cases, you can delay the collection of advertiser_id to obtain user consent or fulfill any legal obligations instead of disabling it entirely. To do so, call the setAdvertiserIDCollectionEnabled() method of the FacebookSDK class and set it to true . This re-enables the collection of advertiser_id after the end-user provides the required consent, as shown:

    setAdvertiserIDCollectionEnabled(true);
  • To suspend collection for any reason, set the setAdvertiserIDCollectionEnabled() method to false, as shown:

    setAdvertiserIDCollectionEnabled(false)

Disable Automatic SDK Initialization

Android To disable automatic SDK initialization in case of the Android SDK, add the following to your AndroidManifest.xml file:

<application>
  ...
  <meta-data androidName="com.facebook.sdk.AutoInitEnabled"
          androidValue="false"/>
  ...
</application>

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 method setAutoInitEnabled and set it to true to manually initialize the SDK after the end-user provides the required consent.

FacebookSdk.setAutoInitEnabled(true)
FacebookSdk.fullyInitialize()

FAQs

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 dashboard.

Where do I get the Facebook Client Token?

You can find the Facebook Client Token by logging into your Facebook Developer account. Then, navigate to Settings - Advanced - Client Token in your app dashboard.

Contact Us

For more information on this option, refer to the section below.

Add the following line to your Podfile :

Make sure you replace fbAPP-ID , APP-ID, CLIENT-TOKEN, APP-NAME with the app-specific details from the .

In July 2020, Facebook released a feature to give businesses better control over how their data is used in their California Consumer Privacy Act (CCPA) compliance efforts.

Learn more about the different data processing options accepted by Facebook .

If you come across any issues while configuring Facebook App Events with RudderStack, feel free to or start a conversation in our community.

Limited Data Use
CocoaPods
Facebook for Developers platform
Limited Data Use
here
contact us
Slack
Facebook App Events
GitHub repo
RudderStack connection modes
RudderStack dashboard