Google Firebase

Google Analytics vs. Google Firebase

If you are a free customer, please as follow the guide below as Google Analytics has been deprecated for free users. If you are a paying Google Analytics customer, please refer to our data integration for Google Analytics.

Overview

With a push of a button you can send your Branch data to your Google Analytics dashboard, helping you understand the power of Branch as an acquisition pathway. If you're interested in the segment of users coming into your apps through Branch and want to measure their events against your other cohorts, this guide can help.

Prerequisites

Events Sent to Google Firebase

Branch will send referred installs and opens, as well as any custom events you track with Branch. Non-referred events, clicks, web session starts, and pageviews will be excluded. Branch also sends over analytics data that is attached to the link, whether it's UTM tags or fields set on the Branch Dashboard (e.g. Campaign, Channel, Feature). This will allow you to analyze which campaigns, channels, etc. are helping you acquire and engage users.

Below is the full list of fields:

Property Name Value Sourced from Example Req
v API version [fixed] 1 Y
tid Tracking ID Google Analytics Dashboard UA-XXXXXX-Y Y
ds Source (mobile SDK) [fixed] app Y
an Application Name [fixed] BRANCH-APP Y
t Type [fixed] event Y
ec Event Category [fixed] BranchEvent Y
uid User Id $google_analytics_user_id User A N
cn Campaign Name utm_campaign -or- Branch campaign "Beaches and breezes" N
cs Campaign Source utm_source -or- Branch channel "Twitter" N
cm Campaign Medium utm_medium -or- Branch feature "480banner" N
ck Campaign Keywords utm_term -or- Branch $keywords ["Keyword1", "keyword3"] N
cc Campaign Content utm_content -or- Branch tags "Some content" N
ea Event Action (Name) event name install Y
uip User’s IP Address collected by Branch SDK 111.111.111.111 N
z Cache buster [unix time + random number] 1461878903666 N

Setup

The code snippets below should be called before you track events via the Firebase SDK. This will not change event counts in Firebase, but rather allows you to augment those Firebase calls with Branch attribution data, when that data is available (i.e., the session or event would've been attributed in Branch). A few things to be aware of when passing this data through:

  • Branch tracks one INSTALL event per user. You can check if +is_first_session is "true" in Branch's SDK callback, to confirm if the session will be tracked as an INSTALL in Branch.
  • Branch frequency caps non-referred OPENs (i.e., OPENS that were not sourced via a deep link), so session counts between Branch & Firebase will not be the same (ask your account manager for your app's frequency cap). Attribution data will still be accessible in app, even if the session won't be tracked in Branch.

Android

  1. Ensure you've completed the Firebase SDK implementation as documented here
  2. Ensure you've completed the Branch SDK implementation as documented here.
  3. In the LauncherActivity#onStart() method of the Branch Android SDK, update the implementation as below:
Branch.getInstance().getLastAttributedTouchData(
                new ServerRequestGetLATD.BranchLastAttributedTouchDataListener() {
                    @Override
                    public void onDataFetched(JSONObject jsonObject, BranchError error) {

                        if (error == null) {
                            if (jsonObject != null) {

                                FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics
                                        .getInstance(getApplicationContext());

                                Bundle bundle = new Bundle();

                                try {
                                    JSONObject latd = jsonObject.getJSONObject("last_attributed_touch_data").getJSONObject("data");
                                    String feature = latd.getString("~feature");
                                    String channel = latd.getString("~channel");
                                    String campaign = latd.getString("~campaign");

                                        bundle.putString("utm_medium", feature);
                                        bundle.putString("utm_source", channel);
                                        bundle.putString("utm_campaign", campaign);

                                    firebaseAnalytics.logEvent("custom_event", bundle);

                                } catch (JSONException ignore) {

                                }

                            }
                        }
                    }
                }, 30);

iOS

  1. Ensure you've completed the Firebase SDK implementation as documented here
  2. Ensure you've completed the Branch SDK implementation as documented here.
  3. In the AppDelegate of the Branch iOS SDK, update the implementation as below:
Branch.getInstance().lastAttributedTouchData(withAttributionWindow: 30) { latd in
            guard let json = latd?.lastAttributedTouchJSON else { return }
            
                if let params = json["data"] as? NSDictionary {
                var firebaseParams = [String: Any]()
                firebaseParams["utm_campaign"] = params["~campaign"] ?? ""
                // get the link feature
                firebaseParams["utm_medium"] = params["~feature"] ?? ""
                // get the link channel
                firebaseParams["utm_source"] = params["~channel"] ?? ""
                // get the link term
                firebaseParams["utm_term"] = params["~keyword"] ?? ""

                Analytics.logEvent("custom_event", parameters: firebaseParams)
}

mParticle for Android and/or iOS

If you use the mParticle plugins alongside the Branch SDK, you must ensure Firebase authenticates before the Branch session is initialized with mParticle. When the Branch session is initialized with mParticle prior to Firebase authentication, the deep link data is not returned.

Using Firebase DebugView

To debug the events and their metadata, you can enable the DebugView on Firebase to verify the setup. Please refer to Google's official instructions here.

image

Common Discrepancies Between Firebase & Branch

  • When the attribution of the custom events occurs in the following sessions after the click (i.e not the session after the immediate click). For example, Click -> app open -> app close -> app open -> Purchase -> Purchase sent to Firebase.

    The above purchase event on Branch might be attributed based on the attribution window, but on the Firebase this will always be organic as the SDK will not have the attribution data.

  • SAN attribution support, for Google UAC (no deep linking) and Facebook App Install (not so reliable deferred deep links), the Firebase installs would miss the attribution data.

NOTE

Please ensure you’ve reviewed your agreements with any ad network (for example Facebook, Snap and Twitter) to ensure your handling of attribution data and use of third party analytics tools is in compliance.

  • As per your account settings, it may be the case where the Fingerprinting attribution is disabled. This means that the deep link will return the link data, but no attribution data will be recorded at Branch’s end. If this is the case (ensure to check with your Account Manager).

Updated 7 days ago

Google Firebase


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.