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

概述
Send your Branch data to your Google Analytics dashboard, helping you understand the power of Branch as an acquisition and re-engagement 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.
它是如何工作的?
Once the Branch SDK is integrated into an app, Branch can detect which Branch Links are leading to opens, installs, re-installs, and down funnel events. Enabling this integration and providing your Google Analytics Tracking Id will result in Branch automatically forwarding events to Google Analytics, in the exact format Google Analytics expects. This includes automatically setting various UTM tags that can be used to determine the source of new users.
Branch Events Sent to Google Analytics
Branch will send installs and opens, commerce, content, user lifecycle, as well as any custom events you track with Branch. Clicks, web session starts, and web pageviews will not be sent. 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. You can see the list of fields that we send to Google Analytics here.
它是什么样子的?
Branch 事件将与您在 Google Analytics(分析)中其他追踪的事件一起显示。这是设置了测试信息的 Sources 屏幕的示例。

To view installs and opens, as well as any custom events you track with Branch as they are occur, navigate to Real-Time > Events. The event category for all Branch events is BranchEvent.

先决条件
In order to enable Google Analytics, 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)
- 实现 Google Analytics(分析)SDK
- Admin access to your Google Analytics account.
Enable Google Analytics
1. Retrieve IDs from Google Analytics
Log into your Google Analytics Dashboard. Make sure that you have admin access.
For Google Analytics 4 you need to retrieve your Measurement ID:
- In Admin, make sure that you have the desired account and property selected.
- In the Property column, click Data Streams, then click your web data stream. Your
G-XXXX
Measurement ID appears in the upper right portion of the panel.

For Universal Analytics (Legacy) you need to retrieve your Tracking ID:
- Go to Admin.
- In the Property column, click Property Settings. Your
UA-XXXX
Tracking ID appears at the top of the Property Settings Page

2. Connect Google Analytics in Branch
In the Branch Dashboard in Data Feeds → Data Integrations tab, find and search for Google Analytics.
Enter the IDs from the previous step. Enter them into the iOS and Android fields in the Branch Dashboard, and hit Save.
Note: If you only have one Measurement/Tracking ID, then enter the same ID for both iOS and Android.
3. Pass Metadata to the Branch SDK
需要开发人员
Developers on your mobile app are required for this step
For a given app session, the unique Google Analytics identifier needs to be passed to the Branch SDK (before the Branch SDK initializes) in order for Branch to properly send events to Google Analytics.
Compatible IDs
Version | 标识符 | Google Shortcode | Branch Metadata Key |
---|---|---|---|
Google Analytics 4 | 用户 ID | uid | $google_analytics_user_id |
Universal Analytics | Client ID (for device identification) | cid | $google_analytics_client_id |
Specify the Branch metadata key for your Google Analytics tracking identifier
Pass User ID to Branch
branch.setRequestMetadataKey("$google_analytics_user_id", "USER-ID-HERE")
Branch.getInstance().setRequestMetadata("$google_analytics_user_id", "USER-ID-HERE");
Pass Client ID to Branch
Note: You just need to pass a random UUID on install and store it in local storage for later use for the Branch SDK.
// Add before initializing Branch session.
let uuid = UUID().uuidString;
let branch = Branch.getInstance();
branch.setRequestMetadataKey("$google_analytics_client_id", uuid)
// Need import java.util.UUID
// Call after instantiating Branch in your application's onCreate before you call Branch initSession
UUID uuid = UUID.randomUUID();
String client_id = uuid.toString();
Branch.getInstance().setRequestMetadata("$google_analytics_client_id",client_id);
4. Verify Data Sent
Once the above steps are complete, you are now ready to start launching campaigns. Branch-attributed conversions will be sent to Google Analytics. To verify data is being sent from Branch to Google Analytics, you can look at the Branch Dashboard's Liveview Webhook Records and apply the following filter:
Filter | Operator | 值 |
---|---|---|
webhook partner key | equals | di_google_analytics |
Wait Period
Please be patient as data may take some time to flow through Branch's attribution systems and onto Google Analytics. If data has not appeared in Google Analytics after 30 minutes of completing a test conversion, review the above steps to see if you may have missed something.
Properties Sent to Google Analytics
Property 名称 | 值 | Sourced From | 例如 | 必要项 |
---|---|---|---|---|
v | API 版本 | [固定] | 1 | 是 |
tid | 追踪号码 | Branch 操作后台 (Dashboard) | UA-XXXXXX-Y | 是 |
ds | Source(移动 SDK) | [固定] | 应用 | 是 |
an | 应用名称 | [固定] | BranchAPP | 是 |
t | 类型 | [固定] | 事件 | 是 |
ec | 事件类别 | [固定] | BranchEvent | 是 |
cid | 客户 ID | (discussed above, includes $google_analytics_client_id ) | AEBE52E7-03EE-455A-B3C4-E57283966239 | 是 |
uid | 用户 ID | $google_analytics_user_id | 用户A | 否 |
cn | Campaign 名称 | utm_campaign or Branch campaign | "Beaches and breezes" | 否 |
cs | Campaign Source | utm_source or Branch channel | "Twitter" | 否 |
cm | Campaign Medium | utm_medium or Branch feature | "480banner" | 否 |
ck | Campaign 关键字 | utm_term or Branch $keywords | ["Keyword1", "keyword3"] | 否 |
cc | Campaign 内容 | utm_content or Branch tags | "Some content" | 否 |
ea | 事件动作(名称) | 事件名称 | install | 是 |
uip | Device IP Address | 由 Branch SDK 收集 | 111.111.111.111 | 否 |
z | Cache buster | [unix time + random number] | 1461878903666 | 否 |
匿名客户 ID
If for some reason Branch does not receive an advertising identifier or hardware identifier, and you do not explicitly specify
$google_analytics_user_id
or$google_analytics_client_id
, then Branch will sendanonymous
as the Client ID (cid
). This is a required field by Google Analytics.
问题排查
会话长度很短或不存在
当 Branch 发送安装和打开时,Google Analytics(分析)将自动启动会话。因此,您应在应用启动时删除所有创建新会话的代码。例如,在 iOS 上,您可能会触发以下事件:
[builder set:@"start" forKey:kGAISessionControl];
您应该删除它,以便您的应用不会启动新的会话。否则,您可能会看到零秒会话,并且平均会话长度下降。
数据未出现在Google Analytics(分析)中
- Check your Measurement/Tracking ID in the Branch Dashboard matches the Measurement/Tracking ID in Google Analytics
- 确保您正在查看 Google Analytics(分析)操作后台 (Dashboard)的正确部分。数据应显示在
Acquisition > Sources > All
- 检查您的 Google Analytics(分析)视图是否没有任何筛选项。例如,如果您的视图筛选掉了英国的用户,而 Branch open 来自英国的用户,则您将不会在视图中看到 Branch 的数据。
Updated 2 months ago