Firebase
Connect Branch and Firebase to unlock a more holistic picture of the customer journey for your app.

概述
只需按一下按钮,就可以将 Branch 数据发送到 Google Analytics(分析)操作后台 (Dashboard),以帮助您了解 Branch 作为获取途径的功能。如果您对通过 Branch 进入您的应用的用户群感兴趣,并希望根据您的其他同类群组来衡量他们的事件,则本指南可以为您提供帮助。
它是如何工作的?
Once the Branch SDK is integrated into an app, Branch can detect which Branch Links are leading to installs, re-opens, and users' actions. Enabling this integration and completing the relevant code will result in Branch automatically forwarding referred events to Google Firebase, in the exact format Firebase expects.
Branch Events Sent to Firebase
Branch 将发送参考的安装,打开,商务,内容,用户生命周期以及您使用 Branch 跟踪的任何自定义事件。未提及的事件,点击,网络会话开始以及浏览量将被排除。Branch 还会发送附加到链接的分析数据,无论是 UTM 标签还是在 Branch 仪表盘上设置的字段(例如广告系列,渠道,功能)。这将使您能够分析哪些广告系列,渠道等正在帮助您获得和吸引用户。
先决条件
In order to enable Firebase, you need to have completed the following:
- Admin access to your Branch Dashboard.
- Enabled Data Feeds for your Branch account.
- Contact your Branch account manager or visit https://branch.io/pricing
- Implemented the Branch SDK into your mobile app (iOS | Android)
- Firebase Analytics SDK
- Admin access to your Firebase account.
Enable Firebase
在通过 Firebase SDK 追踪事件之前,应先调用以下代码片段。这不会更改 Firebase 中的事件计数,而是允许您在可用数据时(例如,会话或事件已在 Branch 中被赋予属性)使用 Branch 归因数据来扩展这些 Firebase 调用。传递数据时要注意的几件事:
- 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 的频次上限是非推荐的 OPEN(即不是通过深度链接获得的 OPEN),因此 Branch&Firebase 之间的会话计数将是不同的(向您的客户经理询问应用的频次上限)。即使不会在 Branch 中追踪会话,仍可以在应用中访问归因数据。
Android
- Ensure you've completed the Firebase SDK implementation as documented here
- Ensure you've completed the Branch SDK implementation as documented here.
- 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
- Ensure you've completed the Firebase SDK implementation as documented here
- Ensure you've completed the Branch SDK implementation as documented here.
- 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)
}
适用于 Android 和/或 iOS 的 mParticle
如果将 mParticle 插件与 Branch SDK 一起使用,则必须确保 Firebase 进行身份验证,然后才能使用 mParticle 初始化 Branch 会话。在 Firebase 身份验证之前使用 mParticle 初始化 Branch 会话时,不返回深度链接数据。
问题排查
使用 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.

Firebase & Branch 之间的常见差异
-
自定义事件的归因发生在点击后的以下会话中(即不是立即点击后的会话)。例如,点击 > 应用打开 > 应用关闭 > 应用打开 > 购买 > 购买发送到 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 归因支持,对于 Google UAC(无深度链接)和 Facebook App Install(不太可靠的延迟深度链接),Firebase 安装会丢失归因数据。
注意
请确保您已查看与任何广告平台(例如 Facebook,Snap 和 Twitter)的协议,以确保您对归因数据的处理和使用第三方分析工具均合规。
- 根据您的帐户设置,可能会禁用通过概率模型进行的归因。这意味着深度链接将返回链接数据,但 Branch 的末尾将不会记录任何归因数据。如果是这种情况(请务必与您的客户经理联系)。
Updated 2 months ago