Facebook Analytics Quickstart Guide for iOS
This Quickstart shows how to integrate Facebook Analytics into a new or existing Swift or Objective-C app.
Please log in to Facebook to create apps or register as a developer.
2. Set up Your Development Environment
a. Install Cocoapods.
sudo gem install cocoapods
b. Install the Facebook SDK.
- Create a new Swift project and go to the project directory. If you are using an existing project, go to project directory of the existing project.
- In a terminal window, run the following command to create a pod file for the project:
- Add the following line to the pod file of your project:
- In the terminal window, run the following command to install the Facebook SDK for Swift:
c. Modify the
- Add the following import statement:
- Add the following statement to the
3. Configure Your Information Property List.
a. Enter you Bundle Identifier (Bundle ID) in the Box.
b. In Xcode, right-click
info.plist and choose Open As Source Code.
c. Copy the XML snippet into the body of your file just before the final
4. Build and then run the project in the SimulatorIn Xcode, select an iOS simulator and click Run. Xcode builds your project and then launches the most recent version of your app running in Simulator.
5. See the Results in the Dashboard.
6. Add a Custom Event
App events are the key actions that people take as they use your app, such as launching your app, viewing content or making a purchase.
You can log app events for any meaningful actions people take in your app. There are many pre-defined events such as completed registration, viewed content, searched, added to cart, spent credits and more.
In this step, you add code to your project that appears as a custom event in the dashboard.a. Add the following code to the
viewDidLoad()function in the
AppEventsLogger.log("My custom event.");
b. Build the project and then run the project in the Simulator.
c. See the results in the Dashboard.
Take a Guided Tour of Facebook Analytics
The demo app does not have an Event Debugging link. This link is only available in apps that you create.
- Log more app events with additional data, including purchase value, custom parameters and more.
- View the Facebook Analytics Help Center, where you'll find frequently asked questions and videos that help you get the most out of your data.
- Read the App Events Best Practices Guide for recommendations regarding which events to use in various types of apps.
- Visit analytics.facebook.com for a great summary of the key features, customer stories and more.