Facebook SDK for App Ads
Create Ad Verify Your App Ads Setup
Add the Facebook SDK for iOS, Android or JavaScript to your app to:
- Measure installs
- Measure app events
- Add deep linking to your ads
- Bring people back to your app
- Improve targeting
- Encourage purchases
- Create re-engagement ads
- Measure in-app conversions
To learn more about these topics read our guides for measuring, targeting and customizing ad formats.
Step-by-Step: Facebook SDK Setup
1. Facebook App ID
You need a Facebook App ID to use the Facebook SDK for iOS, Android or JavaScript (Web). You can use an existing app if you already have one. Otherwise use our Quick Start to create a new app. If you need help follow our how-to Register and Configure an App.
2. Link Ad Accounts
To measure installs in the Facebook Ads Manager you have to associate advertising accounts with your app using the app dashboard.
- Go to the app dashboard
- Choose your app.
- Navigate to "Settings > Advanced" and add accounts via the
Authorized Ad Account IDs
input field.
3. Add the Facebook SDK to your app
Follow the instructions of our "Getting started" guides to add the Facebook SDK to your app:
For iOS / Android: You do not need to add any functionality like Sharing or Login with Facebook.
4. Enable Install Tracking
To enable install tracking call the App Events logger once your application becomes active.
iOS SDK
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
Android SDK
@Override
protected void onResume() {
super.onResume();
AppEventsLogger.activateApp(this);
// ...
}
// Optional: App Deactivation Event
@Override
protected void onPause() {
super.onPause();
AppEventsLogger.deactivateApp(this);
}
Desktop Canvas Apps: By integrating Facebook Login to your Facebook Canvas, App Launches and App Installs are logged automatically. Other Web Apps: We do not support install tracking for web apps not hosted on facebook.com.
5. More Tracking Methods
If you want to track other app events like a person making a purchase, visit our App Events guide.
Example: Log Purchase
iOS SDK
[FBSDKAppEvents logPurchase:4.32 currency:@"USD"];
JavaScript SDK
var params = {}; // optional parameters like `CONTENT_ID`
FB.AppEvents.logPurchase(4.32, "USD", params);
Android SDK
logger.logPurchase(BigDecimal.valueOf(4.32), Currency.getInstance("USD"));
Example: Custom Event
iOS SDK
[FBSDKAppEvents logEvent:@"myCustomEventName"];
JavaScript SDK
FB.AppEvents.logEvent("myCustomEventName");
Android SDK
logger.logEvent("myCustomEventName");
App Events Guide
Verify Setup (for iOS/Android)
Once you completed the step-by-step guide and use your app tracking will start. You can verify that app events and the Facebook SDK are working properly via the App Ads Helper:
Keep in Mind
- App ID: The app ID used in your app must match the app ID used in your ad.
- Advertising Accounts: If you want other people or companies to run ads on behalf of your app, you can associate advertising accounts with your app via the App Dashboard: From the settings tab, choose Advanced > Advertising Accounts.
Next Steps
Enable Deep Linking in your App Create Ad