SOURCES GUIDE

Facebook App Events

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

Facebook App Events allows you to track events via your app or web page. This includes activities such as a user installing the app, completing a purchase, and more. All these information is then used for analytics for better understanding your customer.

RudderStack supports sending your event data to Facebook App Events by adding it as a destination.

Getting Started

To enable sending your event data to Facebook, you will first need to add it as a destination to the source from which you are sending your event data. Once the destination is enabled, events from our SDK will start flowing to Facebook.

Before configuring your source and destination on the RudderStack, please verify if the source platform is supported by Facebook, by referring to the table below:

Connection Mode

Web

Mobile

Server

Device mode

-

Supported

-

Cloud mode

Supported

Supported

-

Once you have confirmed that the platform supports sending events to Facebook, perform the steps below:

Please follow our Adding a Source and Destination guide to add a source and destination in RudderStack.

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

  • Enter the Facebook App Id.

  • Turn on the Use native SDK to send events button so that we can send data to Facebook using the native SDK.

  • Click on Next to complete the configuration.

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 Facebook to your project:

iOS
Android
iOS

To add Facebook to your iOS project:

  • Add the following line to your CocoaPods Podfile

pod 'Rudder-Facebook', '0.1.0-beta.1'
  • After adding the dependency, you must register the RudderFacebookFactory with your RudderClient initialisation 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, change the SDK initialisation to the following:

RudderConfigBuilder *builder = [[RudderConfigBuilder alloc] init];
[builder withDataPlaneUrl:<YOUR_DATA_PLANE_URL>];
[builder withFactory:[RudderFacebookFactory instance]];
[RudderClient getInstance:<YOUR_WRITE_KEY> config:[builder build]];
Android

To add Facebook App Events to your Android project:

  • Add the repository as shown:

repositories {
maven { url "https://dl.bintray.com/rudderstack/rudderstack" }
}
  • Add the following line to your app/build.gradle file under dependencies section:

implementation 'com.rudderstack.android.sdk:core:1.0.1-beta.1'
implementation 'com.rudderstack.android.integration:facebook:0.1.0-beta.1'
  • Finally change the initialisation of your RudderClient in your Application class.

val rudderClient = RudderClient.getInstance(
this,
<YOUT_WRITE_KEY>,
RudderConfig.Builder()
.withDataPlaneUrl(<YOUR_DATA_PLANE_URL>)
.withFactory(FacebookIntegrationFactory.FACTORY)
.build()
)

Identify

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 will look like the below.

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

Track

The track call from RudderStack is logged to Facebook using logEvent method of the AppEventsLogger class. We'll use the eventName as same as you have passed to the track method. Along with that, we'll pass all the properties you've passed after converting it to the accepted format.

A Sample track call for an iOS application will look like the below.

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

Screen

For all the screen calls from the SDK, RudderStack tracks that as track event to Facebook with the eventName as the name of the screen . All the properties are also passed to AppsFlyer as is.

RudderStack performs the same task for the automatically recorded screen calls as well. For those calls, a Boolean property called automatic is obtained in the properties.

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.

Contact Us

If you come across any issues while configuring AppsFlyer with RudderStack, please feel free to contact us or start a conversation on our Discord channel. We will be happy to help you.