Segment (Import)
Send Segment data to Branch to unlock a more holistic picture of the customer journey for your app.

概述
通过将事件从 Segment 发送到 Branch,您可以将下游转化(例如跨平台和应用的购买)归因于 Branch Link 点击。从 Segment 导入到 Branch 的事件将在您通常在 Branch 内使用事件的地方可用,包括操作后台 (Dashboard)可视化,Data Feeds(数据对接),Universal Ads(全域广告归因)回传,Journeys (站到端引流)定位,Liveview 等。
This guide walks through the server-side integration for data import from Segment to Branch. For data export from Branch to Segment, go here.
它是如何工作的?
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 sending your events to Branch will allow Branch to enhance your Segment data with Branch data.
Branch Events Imported from Segment
Branch will import events that are not auto-tracked with the Branch SDKs. This includes commerce, content, user lifecycle, and custom events, and excludes events like clicks and installs. See the full list of supported events and associated mappings here. Branch will only import events that can be tied to a user.
Avoid Duplicate Data
To avoid duplicate data, you should either track conversion events directly with Branch or track events with Segment and then enable import to Branch, not both. Branch will warn you if you try to import events to Branch that you are already tracking.
Branch 仅会从尚未导入 Branch SDK 的自动追踪的 Segment 中导入事件。这意味着无法导入诸如点击和安装之类的事件。下面概述了 Segment 事件如何映射到 Branch 事件,以及如何将其导入到 Branch:
Segment 事件 | Branch Event | Branch 事件类别 | Imported |
---|---|---|---|
Product Added | Add To Cart | Commerce Event | 是 |
Product Added to Wishlist | Add To Wishlist | Commerce Event | 是 |
Cart Viewed | View Cart | Commerce Event | 是 |
Payment Info Entered | Add 付款信息 | Commerce Event | 是 |
Checkout Started | Initiate Purchase | Commerce Event | 是 |
Order Completed | Purchase | Commerce Event | 是 |
使用Branch事件名称 | Spend Credits | Commerce Event | 是 |
Products Searched | Search | Content 事件 | 是 |
Product Viewed | View Item | Content 事件 | 是 |
Product List Viewed | View Items | Content 事件 | 是 |
Product Reviewed | Rate | Content 事件 | 是 |
Product Shared | Share | Content 事件 | 是 |
使用Branch事件名称 | Complete Registration | Lifecycle Event | 是 |
使用Branch事件名称 | Complete Tutorial | Lifecycle Event | 是 |
使用Branch事件名称 | Achieve Level | Lifecycle Event | 是 |
使用Branch事件名称 | Unlock Achievement | Lifecycle Event | 是 |
任何事件名称 | Custom | Custom Event | 是 |
Deep Link Clicked | Click | -- | 否 |
Install Attributed | Install | -- | 否 |
-- | SMS Sent | -- | 否 |
-- | Pageview | -- | 否 |
-- | Web Session Start | -- | 否 |
-- | Branch CTA View | -- | 否 |
-- | Impression | -- | 否 |
Application Installed | -- | -- | 否 |
Application Opened | -- | -- | 否 |
Application Updated | -- | -- | 否 |
Application Backgrounded | -- | -- | 否 |
Application Crashed | -- | -- | 否 |
Application Uninstalled | -- | -- | 否 |
Push Notification Received | -- | -- | 否 |
Push Notification Tapped | -- | -- | 否 |
Push Notification Bounced | -- | -- | 否 |
Screen | -- | -- | 否 |
Page | -- | -- | 否 |
Identify | -- | -- | 否 |
先决条件
In order to enable Segment (import), 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)
- Implement the Segment SDK
- Admin access to your Segment account.
Enable Segment (import)
1. Setup Branch
Contact Branch to configure Branch to receive events from Segment. Please note that a subscription to Data Feeds is required to enable data import from Segment to Branch.
Then, navigate to the Data Integrations page of the Branch dashboard.
1. Select Segment from the menu on the left.
2. Select the platforms you would like to import events from and click Enable.

2. Setup Segment
Navigate to your Segment UI’s Destinations page.
- 点击 Add Destination 。
- 在“目标目录”中搜索 Branch,然后确认您要连接的 Source。
- Enter your Branch Key. This can be found in the Account Settings > App section of the Branch dashboard.
- Enter your Branch Secret. This can be found in the Account Settings > App section of the Branch dashboard.
对于服务器端事件导入, 可以忽略 SDK 集成说明 。
Segment Identifiers
应用事件的标识符
必须输入标识符,事件才能导入到 Branch。您必须包括:
- context.device.advertisingId 和 context.os.name 或
- context.device.id AND context.os.name
Branch 将 Segment 的标识符映射到以下内容:
Segment 字段 | Branch 字段 |
---|---|
userId | developer_identity |
context.device.advertisingId | idfa or aaid |
context.device.id | idfv or android_id |
context.os.name | os |
If using User ID with Segment, Branch will automatically map this to developer identity. See Developer Identity Instructions for ( iOS | Android )
Check out Segment's User ID docs for more details.
Branch does not map Segment's anonymous ID to any field, and will not attribute logged out web events received from the server-to-server integration. Anonymous ID can still be attached to events.
Web Events 的标识符
In order to attribute accurately on web it is important to collect the Branch SDK's browser fingerprint and pass it to the Segment track function. Branch uses this along with the userAgent
collected by the Segment SDK to identify the user's persona, platform, os and other parameters. Collecting the browser fingerprint can be done with the following code snippet:
For Logged in web Events Only
即使传递匿名 ID,Branch 也不会将已注销的 Web Events 归因于 Segment。
const loadBranchAndGetFingerprint = new Promise(function(resolve, reject) {
branch.init('BRANCH_KEY', {}, function(err, data) {
branch.getBrowserFingerprintId(function(err, fingerprint) { // fetch the browser fingerprint from the SDK
if (!!err) {
reject(err);
return;
}
resolve({...data, fingerprint});
});
});
});
然后,您可以将其传递到 Segment 追踪事件的有效负载中:
loadBranchAndGetFingerprint.then(function(data) {
const { fingerprint } = data;
// Load the Segment SDK and initialize with key here
// Segment track request
analytics.track('Order Completed', {
browser_fingerprint_id: fingerprint // add the browser fingerprint to the Segment track event
//... Other event details ...
})
});
Segment Track
The Branch integration supports some of the events tracked with Segment’s Track method. The track API call is how you record any actions your users perform, along with any properties that describe the action.
每个动作都称为一个事件。每个事件都有一个名称(如 Registered)和属性,例如,Registered 事件可能具有诸如 plan 或 accountType 的属性。这是删除了大多数常见字段的典型追踪调用的有效负载:
{
"type": "track",
"event": "Registered",
"properties": {
"plan": "Pro Annual",
"accountType" : "Facebook"
}
}
这是将生成上述有效负载的相应 Javascript 事件:
analytics.track("Registered", {
plan: "Pro Annual",
accountType: "Facebook"
});
See Segment's Track documentation for more details and examples.
3. Verify the integration
一旦在 mParticle 和 Branch 中都开启了导入,事件就会发生。如果 Branch 发生了以下事件,您将在导入卡上看到一个绿点:

Branch imports events from Segment as commerce, user lifecycle, content, or custom events.
使用导入的事件
从细分市场导入到 Branch 的事件将在您通常可以在 Branch 中使用事件的任何地方可用。这包括操作后台 (Dashboard)可视化,Data Feeds(数据对接)(包括数据集成,查询 API,Webhook 和每日导出 API),Universal Ads(全域广告归因)回传,Journeys (站到端引流)定位,Liveview 等。
高级
将匿名 ID 附加到事件
Events imported from Segment with anonymous ID attached will retain that value on the event, and will be available in the custom_data field if exported back out from Branch. To attach anonymous ID to events auto-tracked by Branch (installs, opens, etc.), follow the instructions here.
网络上已注销用户的归因
Branch 使用自定义的内部标识符为 Web 上注销的用户使用。如果启用服务器到服务器从 Segment 到 Branch 的集成,则无法将已注销的 Web Events 从 Segment 中归因于使用 Branch 运行的 Campaign。因此,您可能需要直接使用 Branch Web SDK 追踪 Web Events,同时仍将应用事件服务器从 Segment 发送到服务器。Branch 允许您随后关闭 Web Events 导入,以防止重复数据。
Updated 2 months ago