Important!
This integration works with iOS and Android apps that already have the Google Analytics for Firebase SDK implemented. For the integration to succeed, the AppsFlyer SDK has to collect the app_instance_id
value from the Firebase SDK. See instructions on how to retrieve the app instance ID from the Firebase SDK.
How does it work?
-
When a new install occurs, AppsFlyer sends the touchpoint details— media source, campaign name, and campaign ID—to GA4. It also sends the Firebase SDK's
app_instance_id
to ensure the touchpoint is recorded in GA4 for that user. - When an in-app event occurs, GA4 will attribute the event to the last touchpoint.
Set up Google Analytics (GA4) integration
Follow the instructions below to configure the integration with Google Analytics (GA4).
1. Select Google Analytics (GA4) in the Partner Marketplace
Prerequisite: Before setting up the integration, make sure you contact the partner and open an account with them.
To activate or edit the integration:
- To activate: In AppsFlyer, from the side menu, select Collaborate > Partner Marketplace. To edit: In AppsFlyer, from the side menu, select Collaborate > Active Integrations.
- Search for Google Analytics (GA4) and select it.
- Click Set up integration. You’re directed to the integration setup page.
The Google Analytics configuration only includes the Integration tab.
For a detailed description of the Partner Configuration Window Header, click here.
2. Set GA4 Integration in AppsFlyer
Configure the following settings:
-
In the Integration tab, select the app for the integration and turn Activate partner on.
Note: The toggle must be on (activated) for as long as you work with the partner.
For more details about partner activation please click here.
- In Firebase App ID enter the identifier of the Firebase app. To learn how to locate the Firebase App ID see the Firebase documentation.
- In API Secret enter the API Secret for authenticating the postbacks to Google Analytics. An API Secret is generated through the Google Analytics user interface. To view, edit, or create a secret, follow the instructions in the Google documentation. When instructed to select a web data stream, choose an Android or iOS data stream instead.
- Turn on Customer User ID to send the customer user ID (CUID) instead of the advertising ID (IDFA).
- Under the Default postbacks section, in for users from, select All media sources including organic.
Note
The install postback includes only the details of the touchpoint (media source, campaign name, and campaign ID).
3. Set In app event postbacks
In the Integration tab, map AppsFlyer in-app events to Google Analytics (GA4) events, sent via postbacks.
Note
GA4 does not deduplicate events sent from both the Firebase SDK and AppsFlyer. Therefore, we recommend configuring in-app event postbacks only for events that are not already sent to GA4 via the Firebase SDK.
- Turn on In-app event postbacks.
- Click Add event to add an SDK or server-to-server event to the list. The following table describes the fields to complete:
Parameter name Description AppsFlyer event The name of the event, as received by AppsFlyer either from the SDK integrated into your app or from server-to-server events.
Tip: Don't see the event you are looking for?
- Make sure to activate the event on a device with a non-organic installation, and recheck.
- Type it in AppsFlyer event, then click Create custom.
Read more about custom event mapping.
mapped to partner event The unique name or ID of each event, as defined on the partner's side. Possible mapping configurations are: - Text field: Get the corresponding event ID from the partner.
- Drop-down box: Select the most suitable pre-defined AppsFlyer event.
- As is: Send the events as they are, without name mapping.
for users from Select the sending option for the event: - All media sources including organic: Send postbacks for events attributed to any partner, as well as organic events.
including - No data (default): Send only the event itself without any event values.
- Values and revenue: Send all the event parameters, including the revenue value (if exists in the event).
- Values without revenue: Send all the parameters excluding the revenue value.
- [Optional] Click the Add condition icon () to set conditions for an event.
- Click Save integration.
- Send the event postback mapping
4. Send your developer the postback event mapping
After you have set up the in-app event mapping, send your developer a table where each mapped event corresponds to a row with the following columns:
- AF event: Name of the AppsFlyer event.
-
Mapped to Google event: Name of the event in Google Analytics.
Important!
Don’t use any of the Google reserved events as names for custom Google Analytics events.
-
AF event parameters (MANDATORY): Predefined AppsFlyer event parameters that must be included in the event postback sent to Google Analytics.
Important!
It is mandatory to include all predefined AF event parameters within the event definition exactly as they are listed in the table; failure to do so will result in Google Analytics rejecting the postback.
The event mapping table
The following table includes all the Google Analytics events and their predefined AppsFlyer parameters. Send your developer a table containing just the events that you mapped.
Reserved Google event names
The following event names are reserved and cannot be used as custom event names:
ad_activeview
ad_click
ad_exposure
ad_query
ad_reward
adunit_exposure
app_clear_data
app_exception
app_install
app_remove
app_store_refund
app_update
app_upgrade
dynamic_link_app_open
dynamic_link_app_update
dynamic_link_first_open
error
firebase_campaign
firebase_in_app_message_action
firebase_in_app_message_dismiss
firebase_in_app_message_impression
first_open
first_visit
in_app_purchase
notification_dismiss
notification_foreground
notification_open
notification_receive
notification_send
os_update
session_start
user_engagement
5. Retrieve app instance ID in AppsFlyer SDK
The app instance ID uniquely identifies a specific installation of a Firebase app. This value needs to be retrieved by the SDK from the Firebase SDK.
Let your developer implement the code to:
- Collect the
app_instance_id
field from Firebase. - Call
setAddiotionalData
, before the first launch, to include the app instance ID in installs, sessions, and in-app events.
Kotlin
FirebaseAnalytics.getInstance(this).appInstanceId.addOnCompleteListener { task -> if (task.isSuccessful) { AppsFlyerLib.getInstance().setAdditionalData("app_instance_id", task.result) } }
Java
FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(task -> { if (task.isSuccessful()) { AppsFlyerLib.getInstance().setAdditionalData("app_instance_id", task.getResult()); } });
API reference: setAdditionalData
iOS native
let appInstanceId = Analytics.appInstanceID() AppsFlyerLib.shared().customData = ["app_instance_id": appInstanceId]
Objective C
(void) fetchAnalyticsInstanceId { NSString *instanceID = [FIRAnalytics appInstanceID]; [[AppsFlyerLib shared] setAdditionalData:@{@"app_instance_id": instanceID}]; }
API reference: customData
using Firebase.Analytics; public class AnalyticsManager : MonoBehaviour { private async void Start() { AppsFlyer.initSDK(devKey, appID, this); string appInstanceId = await FirebaseAnalytics.GetAnalyticsInstanceIdAsync(); Dictionary <string, string> customData = new Dictionary<string, string>(); customData.Add("app_instance_id", appInstanceId); AppsFlyer.setAdditionalData(appInstanceId); AppsFlyer.startSDK(); } }
API reference: setAdditionalData
API reference: setAdditionalData
6. Validate the GA4 integration
Make sure the events in the postbacks you send to GA4 are registered and read by Google Analytics. There are two methods advertisers can use to view their data:
- Using GA4 Explorations, you can explore the raw event data with all associated parameters. Prerequisite: Big Query export must be set up in your property)
-
The Events report enables advertisers to view their postback events. The report can be found under one or more report collections.
For example, the Events reports can be found in the Life cycle or the Games reporting collections under Engagement > Events.
For more information on the Events report see the Google documentation. -
The Traffic acquisition report helps you understand where your website and app visitors are coming from.
Under the Life cycle collection go to Acquisition > Traffic Acquisition).
For more information on the Traffic acquisition report, see the Google documentation.