description |
---|
This guide describes how to add and configure Firebase and Google Analytics integration. |
You can send subscription renewal events as well as non-renewing events to Firebase and Google Analytics.
{% hint style="danger" %} Due to significant limitations we recommend using this integration only to send events to Google Analytics for product analysis. Once Google updates this API, we will update limitations. Stay tuned. {% endhint %}
- This integration is in Beta, because Google Analytics API is marked as Beta.
- Conversions export to Google Ads is not currently supported.
- Viewing events sent in A/B experiment results is not currently supported.
- Events are being processed in Firebase & Google Analytics within a few hours (usually 3-6 hours).
- Since Firebase SDK automatically tracks in-app purchases when app is running, you may see increased LTV value because it will be a sum of Firebase and Apphud tracked events. Unfortunately, there is no way to disable automatic purchase events collection from Firebase. So keep this in mind when adding an integration.
- 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.
{% tabs %} {% tab title="Step 1" %}
- Integrate Apphud SDK.
- Integrate Firebase.
- Match Users between Firebase and Apphud and pass instance ID to Apphud. {% endtab %}
{% tab title="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.
{% tab title="Step 3" %} At App stream details page find and copy Firebase App ID field.
{% tab title="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.
{% tab title="Step 5" %} At Apphud go to "Integrations" section and add Firebase:
{% tab title="Step 6" %}
- Paste Firebase App ID.
- Paste Client API Secret.
{% tab title="Step 7" %} You can enable or disable each particular event:
{% tab title="Step 8" %} Enable integration and click Save:
To correctly collect events sent from both Firebase SDK and Apphud server, you need to match User IDs between Apphud and Firebase. Just call:
{% tabs %} {% tab title="Swift" %}
Analytics.setUserID(Apphud.userID())
if let instanceID = Analytics.appInstanceID() {
Apphud.addAttribution(data: nil, from: .firebase, identifer: instanceID, callback: nil)
}
{% endtab %}
{% tab title="Kotlin" %}
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
}
{% endtab %} {% endtabs %}
More information about User ID matching can be found here.
Events are mapped in the following way:
Apphud Event Name | Firebase Event Name |
---|---|
Trial Started | apphud_trial_started |
Trial Converted, Subscription Started, |
purchase |
Trial Canceled, Subscription Canceled, Paywall Checkout Initiated, etc. |
|
Subscription Refunded | refund |
{% hint style="info" %} 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). {% endhint %}
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.
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.
{% hint style="info" %} In order to create custom audience using Apphud User Property you should first create Custom Dimension. See instructions above. {% endhint %}
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.
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.