Google Ads (Firebase & Google Analytics)
This guide describes how to add and configure Firebase and Google Analytics integration.
What is it used for?
Apphud sends subscription events as well as non-renewing events via Google Analytics 4 Measurement Protocol.
- Export conversion events to Google Ads.
- Product Analysis in Google Analytics.
Limitations
- Due to limitation in the Google Analytics 4 Measurement Protocol API events will not show up in Firebase A/B testing results.
- Since it is not possible to disable automatic in-app purchase tracking from Firebase SDK, you may see increased LTV value for your customers in Google Analytics.
Requirements
- Apphud iOS SDK 2.2.0 or higher.
- Apphud Android SDK 1.2.0 or higher.
- Some code is required to properly match users sent from Firebase SDK and Apphud, see instructions below.
How to Add Integration?
Step 1
- Integrate Apphud SDK.
- Integrate Firebase.
- Match Users between Firebase and Apphud and pass instance ID to Apphud.
Step 2
- Open Google Analytics and go to Admin settings of your project.
- Go to Data Streams and open your App's Stream details page.
Step 3
At App stream details page find and copy Firebase App ID field.
Step 4
Under Additional settings go to Measurement Protocol API secrets page and create a new API Secret if it doesn't exist. Copy the value.
Step 5
At Apphud go to "Integrations" section and add Firebase:
Step 6
- Paste Firebase App ID.
- Paste Client API Secret.
Step 7
You can enable or disable each particular event:
Step 8
Enable integration and click Save:
[Required] Match Users
To correctly collect events sent from both Firebase SDK and Apphud server, you need to match User IDs between Apphud and Firebase.
For every app launch call:
Analytics.setUserID(Apphud.userID())
if let instanceID = Analytics.appInstanceID() {
Apphud.addAttribution(data: nil, from: .firebase, identifer: instanceID, callback: nil)
} else {
// app instance id is nil, unable to match user
}
FirebaseAnalytics.getInstance(this).setUserId(Apphud.userId())
FirebaseAnalytics.getInstance(this).appInstanceId.addOnSuccessListener { instanceID ->
Apphud.addAttribution(ApphudAttributionProvider.firebase, null, instanceID)
}.addOnFailureListener {
// Optional - Show some error
}.addOnCanceledListener {
//Optional - Show some error
}
Future<void> _initFirebase() async {
final userId = await Apphud.userID();
await FirebaseAnalytics.instance.setUserId(id: userId);
final identifier = await FirebaseAnalytics.instance.appInstanceId;
await Apphud.addAttribution(provider: ApphudAttributionProvider.firebase, identifier: identifier);
}
More information about User ID matching can be found here.
Link Firebase with Google Analytics and Google Ads
In Firebase open Project Settings > Integrations and set up Google Analytics and optionally Google Ads integrations.
Events Mapping
Google Analytics accepts any event names, however Google Ads accepts only Standard Google Events.
When customizing event names, you may opt to replace the purchase event with another standard event listed in Google's event reference guide. It's essential to ensure that any revenue-related events in Apphud are mapped only to those standard Google Analytics events which require currency
and value
parameters.
However, attempting to map non-revenue events from Apphud, such as apphud_trial_started
, to revenue events in Google Analytics, like purchase
, will result in errors. This mismatch occurs because apphud_trial_started
does not include the currency
and value
parameters, which are mandatory for the purchase
event in Google Analytics. If you wish to rename events like apphud_trial_started
, you should select non-revenue standard events from Google Analytics that do not require specific parameters, such as tutorial_begin
.
Altering event mappings without a clear understanding of the implications can lead to data inaccuracies and integration issues. If you are considering any adjustments to event names or mappings, we recommend consulting with our support team first.
Default Events Mapping
Apphud Event Name | Firebase Event Name |
---|---|
Trial Started | apphud_trial_started |
Trial Converted, Subscription Started, Subscription Renewed and other revenue events. | purchase |
Trial Canceled, Subscription Canceled, Paywall Checkout Initiated, etc. | apphud_trial_canceled , apphud_subscription_canceled , apphud_paywall_checkount_initiated , etc. |
Subscription Refunded | refund |
User Properties
Note
You must have at least one event to be successfully sent to Firebase. When event is processed by Firebase, User Properties will appear in desired selection. Keep in mind that events are being processed in Firebase & Google Analytics within a few hours (usually 3-6 hours).
Besides events, Apphud also sends User Properties to Firebase. This helps you to create custom audiences or Custom Definitions and target specific users in A/B tests or view analytics for specific audience. The list of User Properties and its values can be found here.
Custom Dimensions
In order to use User Properties in your analytics you should first assign them to a custom dimension.
- Open your Firebase Console > Custom Definitions > Create custom dimensions.
- While creating custom dimensions select User scope.
- Enter name and description.
- Select User Property, for example,
apphud_payments_count
. Click Save.
Custom Audiences
Note
In order to create custom audience using Apphud User Property you should first create Custom Dimension. See instructions above.
After creating a custom dimension, you can create custom audiences.
- Open your Firebase Console > Audiences > Create custom dimensions.
- Select Custom > your custom dimension name, for example,
apphud_total_spent
- Edit condition on this property, for example,
> 0
. Click Save. - Custom Audience is now available in both Firebase and Google Analytics.
View Firebase A/B test results in Apphud
You can view results of A/B tests in Apphud by sending remote config values to our service. You will be able to add filter of your test variant for every chart including cohort chart.
See this great blog post for details.
Updated 3 months ago