Set up Facebook as an analytics platform
This article guides you on setting up Facebook as an analytics platform, allowing your game to report telemetry data directly to Facebook.
Prerequisites
1. Set up Facebook as an identity provider
2. Request user authorization for user and device tracking
For iOS 14.5 and later versions, the AppTrackingTransparency framework is required for tracking user data and reporting this data to Facebook.
Add the dependency to the
AppTrackingTransparency.framework
in your app.In the
Info.plist
file, add aNSUserTrackingUsageDescription
key for a purpose string that will be displayed on the user consent screen.Call the
static void RequestTrackingAuthorization();
method of Unity or UE for requesting tracking authorization.noteThis method is compiled on Xcode 12 and later versions and runs on iOS 14.0 and later versions. It sends the request once and the system remembers player's choice. It is no longer prompted unless the player uninstalls and reinstalls the game on the same device.
Step 1: Configure event reporting
Facebook SDK supports reporting automatically logged events and manually logged events. The reported data generally only includes the event name, but additional parameters can be manually added. The time, device operation system, app version, value, and parameter information for reported events could be viewed on the Facebook Events Manager.
Automatically logged events
To enable the reporting of automatically logged events, enable Log in-app events automatically for the platform on which the game is going to be released, in Facebook App Dashboard.
To disable the reporting of automatically logged events, see Disable Automatically Logged Events (iOS) or Disable Automatically Logged Events (Android).
Manually logged events
Facebook requires 2 to 40 alphanumeric characters for event names and parameters. The length of each parameter cannot exceed 100 characters.
To manually log custom events, see the Manually Log Events (iOS) or Manually Log Events (Android).
For more information on Faceboook events reporting, see Meta App Events FAQ.
Funnel events
Supported starting from Player Network SDK V1.20.
To enable Player Network SDK to synchronize the reporting of funnel events to Facebook, add the Facebook channel to the ANALYTICS_REPORT_FUNNEL_CHANNEL
configuration in INTLConfig.ini.
[ANALYTICS]
ANALYTICS_REPORT_FUNNEL_CHANNEL = Facebook
See View reported data in the console to view the reported events.
Step 2: Initialize Analytics
- Unity
- Unreal Engine
Initialize the Analytics module, then call ReportEvent
to start Facebook data reporting.
Initialize the Analytics module, then call ReportEvent
to start Facebook data reporting.
Data reporting acceptance
View reported data in the console
There is some latency (influenced by network environment, network fluctuations for Facebook, or other factors) for the reported events when calling the event reporting API. As a result, it is common to see some reported events without any data. It is recommended to view the data 30 minutes after receiving the callback of a successful reporting.
To view the reported data, go to Facebook Events Manager, and click the name of the reported event.
Event details can be seen by clicking View Recent Events under the corresponding event.
The Facebook Events Manager categorizes events into standard events and custom events.
- Standard events: Currently, only app install and app launch are recognized as standard events. After initialization, the total number of reported events for these will be displayed.
- Custom events: Use the app to configure custom events. Navigate to a custom event to view its name and the total event count.
Acceptance use case 1
- Sub-function module: Reporting
- Feature: Event Reporting
- Test points: Facebook console login, enter a custom event, install the app, launch the app
- Prerequisites: Initialize Analytics module
- Procedure/Input
- Log in to the Facebook console for the first time
- Enter the custom event name and parameters
- Install and enter the app for the first time
- Launch the app
- On the console, export data and view reported events
- Expected output: Information reported successfully. Check the following on the console:
- Enter custom event name and parameters: Reported qty+1
- Install and enter the app for the first time: Reported qty+1
- Launch app: Reported qty+1
Acceptance use case 2
- Sub-function module: ReportRevenue
- Feature: Facebook payment event reporting
- Test points: Query report after requesting
ReportRevenue
(Facebook) - Prerequisite: Network connection is normal
- Procedure/Input
- Request
ReportRevenue
- eventName = customizable, spChannels =
Facebook
, Currency =USD
, Revenue = 100 - Facebook inquiries to report incidents
- DD Platform query
AnalyticsReportRevenue
event
- Request
- Expected output: Information reported successfully.
- Facebook related event statistics +1, click the event details display to display USD100 related values.
- DD Platform successfully queries the event reporting with
methodName
asAnalyticsReportRevenue
andmethod_id=715
.
Acceptance use case 3
- Sub-function module: ReportRevenue
- Feature: Facebook payment event reporting
- Test points: Query report after requesting
ReportRevenue
in disconnected state (Facebook) - Prerequisite: Disconnected network status
- Procedure/Input
- Request
ReportRevenue
- eventName = customizable, spChannels =
Facebook
, Currency =USD
, Revenue = 1000 - Reconnect to the network
- Facebook inquiries to report incidents
- DD Platform query
AnalyticsReportRevenue
event
- Request
- Expected output: Information reported successfully.
- After networking, Facebook related event statistics +1, click the event details display to display USD1000 related values.
- The DD Platform successfully queries the event reporting with
methodName
asAnalyticsReportRevenue
andmethod_id=715
.
Error codes
Error Codes | Error Information |
---|---|
1 | An unknown error occurred |
4 | Application request limit reached |
10 | Application does not have permission for this action |
17 | User request limit reached |
100 | Invalid parameter |
200 | Permission error |
For more information, see Facebook Error Codes.