Segment (Import)


通过将事件从 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.

Branch 会导入什么事件?

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.


  1. 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.

  2. Navigate to the Data Integrations page of the Branch dashboard.

    1. 从左侧菜单中选择 Segment
    2. 选择您要从中导入事件的平台,然后点击 Save


  3. 前往您的 Segment 用户界面的“目标”页面。

    1. 点击 Add Destination
    2. 在“目标目录”中搜索 Branch,然后确认您要连接的 Source。
    3. Enter your Branch Key. This can be found in the Account Settings > App section of the Branch dashboard.
    4. Enter your Branch Secret. This can be found in the Account Settings > App section of the Branch dashboard.

对于服务器端事件导入, 可以忽略 SDK 集成说明



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.


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.


Branch 仅会从尚未导入 Branch SDK 的自动追踪的 Segment 中导入事件。这意味着无法导入诸如点击和安装之类的事件。下面概述了 Segment 事件如何映射到 Branch 事件,以及如何将其导入到 Branch:

Segment 事件Branch EventBranch 事件类别Imported
Product AddedAdd To CartCommerce Event
Product Added to WishlistAdd To WishlistCommerce Event
Cart ViewedView CartCommerce Event
Payment Info EnteredAdd 付款信息Commerce Event
Checkout StartedInitiate PurchaseCommerce Event
Order CompletedPurchaseCommerce Event
使用Branch事件名称Spend CreditsCommerce Event
Products SearchedSearchContent 事件
Product ViewedView ItemContent 事件
Product List ViewedView ItemsContent 事件
Product ReviewedRateContent 事件
Product SharedShareContent 事件
使用Branch事件名称Complete RegistrationLifecycle Event
使用Branch事件名称Complete TutorialLifecycle Event
使用Branch事件名称Achieve LevelLifecycle Event
使用Branch事件名称Unlock AchievementLifecycle Event
任何事件名称CustomCustom Event
Deep Link ClickedClick--
Install AttributedInstall--
--SMS Sent--
--Web Session Start--
--Branch CTA View--
--Web to App Auto Redirect--
Application Installed----
Application Opened----
Application Updated----
Application Backgrounded----
Application Crashed----
Application Uninstalled----
Push Notification Received----
Push Notification Tapped----
Push Notification Bounced----


必须输入标识符,事件才能导入到 Branch。您必须包括:

  • context.device.advertisingId 和 或
  • 和 或

Branch 将 Segment 的标识符映射到以下内容:

Segment 字段Branch 字段
context.device.advertisingIdidfa or aaid
context.device.ididfv or android_id

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:


仅适用于登录的 Web Events

即使传递匿名 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) {
    resolve({, 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 和 Branch 中都打开了导入功能,事件就会发生。如果 Branch 发生了以下事件,您将在导入卡上看到一个绿点:


To see more information on the events that are coming in, you can look at events with origin SEGMENT in Liveview:


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 导入,以防止重复数据。