跟踪商务,内容,生命周期和自定义事件

概述

它'总是那么可以跟踪与BranchSDK事件,包括安装,打开,采购,等等。现在,我们重新引入了一种跟踪事件的新方法,这些事件使报告和分析变得更好,更容易。

新的v2事件在Branch仪表板中具有更好的跟踪和分析选项,新的事件结构使与第三方分析提供程序的集成更快,更紧密。

我们重新标准化了您跟踪"类"事件的方式。例如:与客户购买相关的所有事件都存储在"购买"类数据项中,与用户与您的应用内内容进行交互的所有相关事件都与"内容"类数据项相关联。

下面是种你的事件的例子会可能感兴趣的跟踪,我们会告诉您通过我们的SDK来追踪的方式。

验收

跟踪这些事件将传播到Criteo等广告网络。例如,如果您通过“Branch”跟踪购买事件,则它将映射到Criteo的购买事件。

这些事件还将具有分析功能,因此您可以使用新的基于人员的归因来了解其效果。

局限性

到目前为止,通过这些SDK方法进行的任何调用将为而不是

  • 使用我们的推荐系统
  • 除了 导出 之外,还在Branch仪表板中显示自定义数据。

可用事件

使用下表快速找到您要跟踪的事件。

活动名称 活动类别 iOS 安卓 网络和API
Add To Cart 商业活动 BranchStandardEventAddToCart BRANCH_STANDARD_EVENT.ADD_TO_CART ADD_TO_CART
Add To Wishlist 商业活动 BranchStandardEventAddToWishlist BRANCH_STANDARD_EVENT.ADD_TO_WISHLIST ADD_TO_WISHLIST
View Cart 商业活动 BranchStandardEventViewCart BRANCH_STANDARD_EVENT.VIEW_CART VIEW_CART
Initiate Purchase 商业活动 BranchStandardEventInitiatePurchase BRANCH_STANDARD_EVENT.INITIATE_PURCHASE INITIATE_PURCHASE
Add Payment Info 商业活动 BranchStandardEventAddPaymentInfo BRANCH_STANDARD_EVENT.ADD_PAYMENT_INFO ADD_PAYMENT_INFO
Click Ad 商业活动 BranchStandardEventClickAd BRANCH_STANDARD_EVENT.CLICK_AD CLICK_AD
Purchase 商业活动 BranchStandardEventPurchase BRANCH_STANDARD_EVENT.PURCHASE PURCHASE
Spend Credits 商业活动 BranchStandardEventSpendCredits BRANCH_STANDARD_EVENT.SPEND_CREDITS SPEND_CREDITS
Start Trial 生命周期事件 BranchStandardEventStartTrial BRANCH_STANDARD_EVENT.START_TRIAL START_TRIAL
Subscribe 生命周期事件 BranchStandardEventSubscribe BRANCH_STANDARD_EVENT.SUBSCRIBE SUBSCRIBE
View Ad 商业活动 BranchStandardEventViewAd BRANCH_STANDARD_EVENT.VIEW_AD VIEW_AD
Search 内容事件 BranchStandardEventSearch BRANCH_STANDARD_EVENT.SEARCH SEARCH
View Item 内容事件 BranchStandardEventViewItem BRANCH_STANDARD_EVENT.VIEW_ITEM VIEW_ITEM
View Items 内容事件 BranchStandardEventViewItems BRANCH_STANDARD_EVENT.VIEW_ITEMS VIEW_ITEMS
Rate 内容事件 BranchStandardEventRate BRANCH_STANDARD_EVENT.RATE RATE
Share 内容事件 BranchStandardEventShare BRANCH_STANDARD_EVENT.SHARE SHARE
Complete Registration 生命周期事件 BranchStandardEventCompleteRegistration BRANCH_STANDARD_EVENT.COMPLETE_REGISTRATION COMPLETE_REGISTRATION
Complete Tutorial 生命周期事件 BranchStandardEventCompleteTutorial BRANCH_STANDARD_EVENT.COMPLETE_TUTORIAL COMPLETE_TUTORIAL
Achieve Level 生命周期事件 BranchStandardEventAchieveLevel BRANCH_STANDARD_EVENT.ACHIEVE_LEVEL ACHIEVE_LEVEL
Unlock Achievement 生命周期事件 BranchStandardEventUnlockAchievement BRANCH_STANDARD_EVENT.UNLOCK_ACHIEVEMENT UNLOCK_ACHIEVEMENT
Invite 生命周期事件 BranchStandardEventInvite BRANCH_STANDARD_EVENT.INVITE INVITE
Login 生命周期事件 BranchStandardEventLogin BRANCH_STANDARD_EVENT.LOGIN LOGIN
Reserve 生命周期事件 BranchStandardEventReserve BRANCH_STANDARD_EVENT.RESERVE RESERVE

跟踪商务活动

商务事件描述与客户与您的产品进行交互并通过购买进行转化相关的事件。这些事件包括添加付款信息,购买,查看产品等。如果启用了Branch Universal Ads,这些事件将自动映射到某些广告合作伙伴。首先为与您重新跟踪的事件相关联的每个产品创建一个Branch通用对象。

从那里,将Branch通用对象添加到跟踪的事件,并使用正确的预定义常量。例如,下面的代码片段用于跟踪用户何时将其添加到购物车,但只需将该常量替换为另一个常量即可跟踪不同的事件。

有关货币和汇率的说明:
如果您跟踪没有货币的商业活动,我们将其视为美元。如果您使用美元以外的货币跟踪商业活动,我们将使用最近的汇率将指定的revenue 转换为USD。

由于所有单位均为美元,因此,您可以轻松地在仪表板上显示许多国家和货币的收入。定期从 openexchangerates.org 拉出汇率,并且通常在实时汇率的一小时之内。如果您通过Webhooks或Exports查看原始Branch事件,则可以看到所使用的汇率。

iOS-商业

// Create a BranchUniversalObject with your content data:
let branchUniversalObject = BranchUniversalObject.init()

// ...add data to the branchUniversalObject as needed...
branchUniversalObject.canonicalIdentifier = "item/12345"
branchUniversalObject.canonicalUrl        = "https://branch.io/item/12345"
branchUniversalObject.title               = "My Item Title"

branchUniversalObject.contentMetadata.contentSchema     = .commerceProduct
branchUniversalObject.contentMetadata.quantity          = 1
branchUniversalObject.contentMetadata.price             = 23.20
branchUniversalObject.contentMetadata.currency          = .USD
branchUniversalObject.contentMetadata.sku               = "1994320302"
branchUniversalObject.contentMetadata.productName       = "my_product_name1"
branchUniversalObject.contentMetadata.productBrand      = "my_prod_Brand1"
branchUniversalObject.contentMetadata.productCategory   = .apparel
branchUniversalObject.contentMetadata.productVariant    = "XL"
branchUniversalObject.contentMetadata.condition         = .new
branchUniversalObject.contentMetadata.customMetadata = [
            "custom_key1": "custom_value1",
            "custom_key2": "custom_value2"
        ]

// Create a BranchEvent:
let event = BranchEvent.standardEvent(.purchase)

// Add the BranchUniversalObject with the content (do not add an empty branchUniversalObject):
event.contentItems     = [ branchUniversalObject ]

// Add relevant event data:
event.alias            = "my custom alias"
event.transactionID    = "12344555"
event.currency         = .USD
event.revenue          = 1.5
event.shipping         = 10.2
event.tax              = 12.3
event.coupon           = "test_coupon"
event.affiliation      = "test_affiliation"
event.eventDescription = "Event_description"
event.searchQuery      = "item 123"
event.customData       = [
    "Custom_Event_Property_Key1": "Custom_Event_Property_val1",
    "Custom_Event_Property_Key2": "Custom_Event_Property_val2"
]
event.logEvent() // Log the event.
// Create a BranchUniversalObject with your content data:
BranchUniversalObject *branchUniversalObject = [BranchUniversalObject new];

// ...add data to the branchUniversalObject as needed...
branchUniversalObject.canonicalIdentifier = @"item/12345";
branchUniversalObject.canonicalUrl        = @"https://branch.io/item/12345";
branchUniversalObject.title               = @"My Item Title";

branchUniversalObject.contentMetadata.contentSchema     = BranchContentSchemaCommerceProduct;
branchUniversalObject.contentMetadata.quantity          = @"1";
branchUniversalObject.contentMetadata.price             = 23.20;
branchUniversalObject.contentMetadata.currency          = BNCCurrencyUSD;
branchUniversalObject.contentMetadata.sku               = @"1994320302";
branchUniversalObject.contentMetadata.productName       = @"my_product_name1";
branchUniversalObject.contentMetadata.productBrand      = @"my_prod_Brand1";
branchUniversalObject.contentMetadata.productCategory   = BNCProductCategoryApparel;
branchUniversalObject.contentMetadata.productVariant    = @"XL";
branchUniversalObject.contentMetadata.condition         = @"NEW";
branchUniversalObject.contentMetadata.customMetadata =  (NSMutableDictionary*) @{
    @"content_custom_key1": @"content_custom_value1",
    @"content_custom_key2": @"content_custom_value2"
};

// Create an event and add the BranchUniversalObject to it.
BranchEvent *event     = [BranchEvent standardEvent:BranchStandardEventAddToCart];

// Add the BranchUniversalObjects with the content (do not add an empty branchUniversalObject):
event.contentItems     = (id) @[ branchUniversalObject ];

// Add relevant event data:
event.alias            = "my custom alias";
event.transactionID    = @"12344555";
event.currency         = BNCCurrencyUSD;
event.revenue          = [NSDecimalNumber decimalNumberWithString:@"1.5"];
event.shipping         = [NSDecimalNumber decimalNumberWithString:@"10.2"];
event.tax              = [NSDecimalNumber decimalNumberWithString:@"12.3"];
event.coupon           = @"test_coupon";
event.affiliation      = @"test_affiliation";
event.eventDescription = @"Event_description";
event.searchQuery      = @"item 123";
event.customData       = (NSMutableDictionary*) @{
    @"Custom_Event_Property_Key1": @"Custom_Event_Property_val1",
    @"Custom_Event_Property_Key2": @"Custom_Event_Property_val2"
};
[event logEvent];

Android-商业

BranchUniversalObject buo = new BranchUniversalObject()
	.setCanonicalIdentifier("myprod/1234")
	.setCanonicalUrl("https://test_canonical_url")
	.setTitle("test_title")
	.setContentMetadata(
	    new ContentMetadata()
		.addCustomMetadata("custom_metadata_key1", "custom_metadata_val1")
		.addCustomMetadata("custom_metadata_key1", "custom_metadata_val1")
		.addImageCaptions("image_caption_1", "image_caption2", "image_caption3")
		.setAddress("Street_Name", "test city", "test_state", "test_country", "test_postal_code")
		.setRating(5.2, 6.0, 5)
		.setLocation(-151.67, -124.0)
		.setPrice(10.0, CurrencyType.USD)
		.setProductBrand("test_prod_brand")
		.setProductCategory(ProductCategory.APPAREL_AND_ACCESSORIES)
		.setProductName("test_prod_name")
		.setProductCondition(ContentMetadata.CONDITION.EXCELLENT)
		.setProductVariant("test_prod_variant")
		.setQuantity(1.5)
		.setSku("test_sku")
		.setContentSchema(BranchContentSchema.COMMERCE_PRODUCT))
	    .addKeyWord("keyword1")
	    .addKeyWord("keyword2");

//  Do not add an empty branchUniversalObject to the BranchEvent

new BranchEvent(BRANCH_STANDARD_EVENT.ADD_TO_CART)
        .setAffiliation("test_affiliation")
        .setCustomerEventAlias("my_custom_alias")
        .setCoupon("Coupon Code")
        .setCurrency(CurrencyType.USD)
        .setDescription("Customer added item to cart")
        .setShipping(0.0)
        .setTax(9.75)
        .setRevenue(1.5)
        .setSearchQuery("Test Search query")
        .addCustomDataProperty("Custom_Event_Property_Key1", "Custom_Event_Property_val1")
        .addCustomDataProperty("Custom_Event_Property_Key2", "Custom_Event_Property_val2")
        .addContentItems(buo)
        .logEvent(context);

网络商务

var event_and_custom_data = {
   "transaction_id": "tras_Id_1232343434",
   "currency": "USD",
   "revenue": 180.2,
   "shipping": 10.5,
   "tax": 13.5,
   "coupon": "promo-1234",
   "affiliation": "high_fi",
   "description": "Preferred purchase",
   "purchase_loc": "Palo Alto",
   "store_pickup": "unavailable"
};

var content_items = [
{
   "$content_schema": "COMMERCE_PRODUCT",
   "$og_title": "Nike Shoe",
   "$og_description": "Start loving your steps",
   "$og_image_url": "http://example.com/img1.jpg",
   "$canonical_identifier": "nike/1234",
   "$publicly_indexable": false,
   "$price": 101.2,
   "$locally_indexable": true,
   "$quantity": 1,
   "$sku": "1101123445",
   "$product_name": "Runner",
   "$product_brand": "Nike",
   "$product_category": "Sporting Goods",
   "$product_variant": "XL",
   "$rating_average": 4.2,
   "$rating_count": 5,
   "$rating_max": 2.2,
   "$creation_timestamp": 1499892854966,
   "$exp_date": 1499892854966,
   "$keywords": [ "sneakers", "shoes" ],
   "$address_street": "230 South LaSalle Street",
   "$address_city": "Chicago",
   "$address_region": "IL",
   "$address_country": "US",
   "$address_postal_code": "60604",
   "$latitude": 12.07,
   "$longitude": -97.5,
   "$image_captions": [ "my_img_caption1", "my_img_caption_2" ],
   "$condition": "NEW",
   "$custom_fields": {"foo1":"bar1","foo2":"bar2"}
},
{
   "$og_title": "Nike Woolen Sox",
   "$canonical_identifier": "nike/5324",
   "$og_description": "Fine combed woolen sox for those who love your foot",
   "$publicly_indexable": false,
   "$price": 80.2,
   "$locally_indexable": true,
   "$quantity": 5,
   "$sku": "110112467",
   "$product_name": "Woolen Sox",
   "$product_brand": "Nike",
   "$product_category": "Apparel & Accessories",
   "$product_variant": "Xl",
   "$rating_average": 3.3,
   "$rating_count": 5,
   "$rating_max": 2.8,
   "$creation_timestamp": 1499892854966
}];

var customer_event_alias = "my custom alias";

branch.logEvent(
   "PURCHASE",
   event_and_custom_data,
   content_items,
   customer_event_alias,
   function(err) { console.log(err); }
);

HTTP API-商业

终点

POST /v2/event/standard
Content-Type: application/json

参量

关于必需标识符的说明。您必须发送(在user_data中):

developer_identity或
browser_fingerprint_id或
os = iOS AND(idfa或idfv)或
os = Android AND(android_id或aaid)

curl -vvv -d '{
  "name": "PURCHASE",
  "customer_event_alias": "my custom alias",
  "user_data": {
    "os": "Android",
    "os_version": 25,
    "environment": "FULL_APP",
    "aaid": "abcdabcd-0123-0123-00f0-000000000000",
    "android_id": "a12300000000",
    "limit_ad_tracking": false,
    "developer_identity": "user123",
    "country": "US",
    "language": "en",
    "ip": "192.168.1.1",
    "local_ip": "192.168.1.2",
    "brand": "LGE",
    "app_version": "1.0.0",
    "model": "Nexus 5X",
    "screen_dpi": 420,
    "screen_height": 1794,
    "screen_width": 1080
  },
  "custom_data": {
    "purchase_loc": "Palo Alto",
    "store_pickup": "unavailable"
  },
  "event_data": {
    "transaction_id": "trans_Id_1232343434",
    "currency": "USD",
    "revenue": 180.2,
    "shipping": 10.5,
    "tax": 13.5,
    "coupon": "promo-1234",
    "affiliation": "high_fi",
    "description": "Preferred purchase"
  },
  "content_items": [
    {
      "$content_schema": "COMMERCE_PRODUCT",
      "$og_title": "Nike Shoe",
      "$og_description": "Start loving your steps",
      "$og_image_url": "http://example.com/img1.jpg",
      "$canonical_identifier": "nike/1234",
      "$publicly_indexable": false,
      "$price": 101.2,
      "$locally_indexable": true,
      "$quantity": 1,
      "$sku": "1101123445",
      "$product_name": "Runner",
      "$product_brand": "Nike",
      "$product_category": "Sporting Goods",
      "$product_variant": "XL",
      "$rating_average": 4.2,
      "$rating_count": 5,
      "$rating_max": 2.2,
      "$creation_timestamp": 1499892854966,
      "$exp_date": 1499892854966,
      "$keywords": [
        "sneakers",
        "shoes"
      ],
      "$address_street": "230 South LaSalle Street",
      "$address_city": "Chicago",
      "$address_region": "IL",
      "$address_country": "US",
      "$address_postal_code": "60604",
      "$latitude": 12.07,
      "$longitude": -97.5,
      "$image_captions": [
        "my_img_caption1",
        "my_img_caption_2"
      ],
      "$condition": "NEW",
      "$custom_fields": "{\"foo1\":\"bar1\",\"foo2\":\"bar2\"}"
    },
    {
      "$og_title": "Nike Woolen Sox",
      "$canonical_identifier": "nike/5324",
      "$og_description": "Fine combed woolen sox for those who love your foot",
      "$publicly_indexable": false,
      "$price": 80.2,
      "$locally_indexable": true,
      "$quantity": 5,
      "$sku": "110112467",
      "$product_name": "Woolen Sox",
      "$product_brand": "Nike",
      "$product_category": "Apparel & Accessories",
      "$product_variant": "Xl",
      "$rating_average": 3.3,
      "$rating_count": 5,
       "$rating_max": 2.8,
      "$creation_timestamp": 1499892854966
     }
   ],
   "metadata": {},
   "branch_key": "key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc"
 }' https://api2.branch.io/v2/event/standard

跟踪内容事件

内容事件是用户与您的应用内内容互动时发生的事件。例如,如果您有应用内文章,则希望跟踪与用户搜索,查看内容,对内容进行评级和共享时有关的事件。这可以应用于多种应用程序内内容,例如博客文章,音乐,视频,图片和电子商务目录项。

iOS-内容

let event = BranchEvent.standardEvent(.search)
event.alias = "my custom alias"
event.eventDescription = "Product Search"
event.searchQuery = "user search query terms for product xyz"
event.customData["Custom_Event_Property_Key1"] = "Custom_Event_Property_val1"
event.logEvent()
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventSearch];
event.alias = "my custom alias";
event.eventDescription = @"Product Search";
event.searchQuery = @"user search query terms for product xyz";
event.customData[@"Custom_Event_Property_Key1"] = @"Custom_Event_Property_val1";
[event logEvent];

Android-内容

new BranchEvent(BRANCH_STANDARD_EVENT.SEARCH)
  .setCustomerEventAlias("my_custom_alias")
  .setDescription("Product Search")
  .setSearchQuery("product name")
  .addCustomDataProperty("Custom_Event_Property_Key1", "Custom_Event_Property_val1")
  .logEvent(context);

网页内容

var event_and_custom_data = {
   "transaction_id": "tras_Id_1232343434",
   "currency": "USD",
   "revenue": 180.2,
   "shipping": 10.5,
   "tax": 13.5,
   "coupon": "promo-1234",
   "affiliation": "high_fi",
   "description": "Preferred purchase",
   "purchase_loc": "Palo Alto",
   "store_pickup": "unavailable"
};

var content_items = [
{
   "$content_schema": "COMMERCE_PRODUCT",
   "$og_title": "Nike Shoe",
   "$og_description": "Start loving your steps",
   "$og_image_url": "http://example.com/img1.jpg",
   "$canonical_identifier": "nike/1234",
   "$publicly_indexable": false,
   "$price": 101.2,
   "$locally_indexable": true,
   "$quantity": 1,
   "$sku": "1101123445",
   "$product_name": "Runner",
   "$product_brand": "Nike",
   "$product_category": "Sporting Goods",
   "$product_variant": "XL",
   "$rating_average": 4.2,
   "$rating_count": 5,
   "$rating_max": 2.2,
   "$creation_timestamp": 1499892854966,
   "$exp_date": 1499892854966,
   "$keywords": [ "sneakers", "shoes" ],
   "$address_street": "230 South LaSalle Street",
   "$address_city": "Chicago",
   "$address_region": "IL",
   "$address_country": "US",
   "$address_postal_code": "60604",
   "$latitude": 12.07,
   "$longitude": -97.5,
   "$image_captions": [ "my_img_caption1", "my_img_caption_2" ],
   "$condition": "NEW",
   "$custom_fields": {"foo1":"bar1","foo2":"bar2"}
},
{
   "$og_title": "Nike Woolen Sox",
   "$canonical_identifier": "nike/5324",
   "$og_description": "Fine combed woolen sox for those who love your foot",
   "$publicly_indexable": false,
   "$price": 80.2,
   "$locally_indexable": true,
   "$quantity": 5,
   "$sku": "110112467",
   "$product_name": "Woolen Sox",
   "$product_brand": "Nike",
   "$product_category": "Apparel & Accessories",
   "$product_variant": "Xl",
   "$rating_average": 3.3,
   "$rating_count": 5,
   "$rating_max": 2.8,
   "$creation_timestamp": 1499892854966
}];

var customer_event_alias = "my custom alias";

branch.logEvent(
   "VIEW_ITEMS",
   event_and_custom_data,
   content_items,
   customer_event_alias,
   function(err) { console.log(err); }
);

HTTP API-内容

终点

POST /v2/event/standard
Content-Type: application/json

参量

关于必需标识符的说明。您必须发送(在user_data中):

developer_identity或
browser_fingerprint_id或
os = iOS AND(idfa或idfv)或
os = Android AND(android_id或aaid)

curl -vvv -d '{
  "name": "VIEW_ITEMS",
  "customer_event_alias": "my custom alias",
  "user_data": {
    "os": "Android",
    "os_version": 25,
    "environment": "FULL_APP",
    "aaid": "abcdabcd-0123-0123-00f0-000000000000",
    "android_id": "a12300000000",
    "limit_ad_tracking": false,
    "developer_identity": "user123",
    "country": "US",
    "language": "en",
    "ip": "192.168.1.1",
    "local_ip": "192.168.1.2",
    "brand": "LGE",
    "app_version": "1.0.0",
    "model": "Nexus 5X",
    "screen_dpi": 420,
    "screen_height": 1794,
    "screen_width": 1080
  },
  "custom_data": {
    "purchase_loc": "Palo Alto",
    "store_pickup": "unavailable"
  },
  "event_data": {
    "search_query": "red sneakers",
    "description": "Preferred purchase"
  },
  "content_items": [
    {
      "$content_schema": "COMMERCE_PRODUCT",
      "$og_title": "Nike Shoe",
      "$og_description": "Start loving your steps",
      "$og_image_url": "http://example.com/img1.jpg",
      "$canonical_identifier": "nike/1234",
      "$publicly_indexable": false,
      "$price": 101.2,
      "$locally_indexable": true,
      "$sku": "1101123445",
      "$product_name": "Runner",
      "$product_brand": "Nike",
      "$product_category": "Sporting Goods",
      "$product_variant": "XL",
      "$rating_average": 4.2,
      "$rating_count": 5,
      "$rating_max": 2.2,
      "$creation_timestamp": 1499892854966,
      "$exp_date": 1499892854966,
      "$keywords": [
        "sneakers",
        "shoes"
      ],
      "$address_street": "230 South LaSalle Street",
      "$address_city": "Chicago",
      "$address_region": "IL",
      "$address_country": "US",
      "$address_postal_code": "60604",
      "$latitude": 12.07,
      "$longitude": -97.5,
      "$image_captions": [
        "my_img_caption1",
        "my_img_caption_2"
      ],
      "$condition": "NEW",
      "$custom_fields": "{\"foo1\":\"bar1\",\"foo2\":\"bar2\"}"
    },
    {
      "$og_title": "Nike Woolen Sox",
      "$canonical_identifier": "nike/5324",
      "$og_description": "Fine combed woolen sox for those who love your foot",
      "$publicly_indexable": false,
      "$price": 80.2,
      "$locally_indexable": true,
      "$sku": "110112467",
      "$product_name": "Woolen Sox",
      "$product_brand": "Nike",
      "$product_category": "Apparel & Accessories",
      "$product_variant": "Xl",
      "$rating_average": 3.3,
      "$rating_count": 5,
      "$rating_max": 2.8,
      "$creation_timestamp": 1499892854966
    }
  ],
  "metadata": {},
  "branch_key": "key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc"
}' https://api2.branch.io/v2/event/standard

跟踪生命周期事件

生命周期事件可以描述为用户进入应用程序以继续进行过程的事件。当用户完成用户个人资料,注册或教程时,这些事件可以应用于游戏应用程序以及非游戏应用程序。

iOS-生命周期

let event = BranchEvent.standardEvent(.completeRegistration)
event.alias = "my custom alias"
event.transactionID = "tx1234"
event.eventDescription = "User completed registration."
event.customData["registrationID"] = "12345"
event.logEvent()
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventCompleteRegistration];
event.alias = "my custom alias";
event.transactionID = @"tx1234";
event.eventDescription = @"User completed registration.";
event.customData[@"registrationID"] = @"12345";
[event logEvent];

Android-生命周期

new BranchEvent(BRANCH_STANDARD_EVENT.COMPLETE_REGISTRATION)
    .setCustomerEventAlias("my_custom_alias")
    .setTransactionID("tx1234")
    .setDescription("User created an account")
    .addCustomDataProperty("registrationID", "12345")
    .logEvent(context);

网络-生命周期

var event_and_custom_data = {
   "transaction_id": "tras_Id_1234",
   "description": "Preferred purchase",
   "registration_id": "12345"
};

var customer_event_alias = "my custom alias";

branch.logEvent(
   "COMPLETE_REGISTRATION",
   event_and_custom_data,
   content_items,
   customer_event_alias,
   function(err) { console.log(err); }
);

HTTP API-生命周期

终点

POST /v2/event/standard
Content-Type: application/json

参量

关于必需标识符的说明。您必须发送(在user_data中):

developer_identity或
browser_fingerprint_id或
os = iOS AND(idfa或idfv)或
os = Android AND(android_id或aaid)

curl -vvv -d '{
  "name": "COMPLETE_REGISTRATION",
  "customer_event_alias": "my custom alias",
  "user_data": {
    "os": "Android",
    "os_version": 25,
    "environment": "FULL_APP",
    "aaid": "abcdabcd-0123-0123-00f0-000000000000",
    "android_id": "a12300000000",
    "limit_ad_tracking": false,
    "developer_identity": "user123",
    "country": "US",
    "language": "en",
    "ip": "192.168.1.1",
    "local_ip": "192.168.1.2",
    "brand": "LGE",
    "app_version": "1.0.0",
    "model": "Nexus 5X",
    "screen_dpi": 420,
    "screen_height": 1794,
    "screen_width": 1080
  },
  "custom_data": {
    "foo": "bar"
  },
  "event_data": {
    "description": "Preferred purchase"
  },
  "metadata": {},
  "branch_key": "key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc"
}' https://api2.branch.io/v2/event/standard

跟踪自定义事件

如果要跟踪不是预定义事件的事件,只需执行以下操作:

自定义事件名称

名称custom event 由Branch保留。请确保您为自定义事件指定一个实际名称。

强烈建议使用不超过40个字符,仅包含字母,数字,连字符,空格和下划线且不要以连字符开头的自定义事件名称。 Facebook将不接受违反这些规则的事件,如果您启用Facebook集成,Branch可能会清理您的事件名称以通过验证。

iOS-自订

let event = BranchEvent.customEventWithName("User_Scanned_Item")
	event.customData[Custom_Event_Property_Key1] =Custom_Event_Property_val1"
	event.customData[Custom_Event_Property_Key2] =Custom_Event_Property_val2"
  event.alias = "my custom alias"
	event.logEvent()
BranchEvent *event = [BranchEvent customEventWithName:@"User_Scanned_Item"];
event.customData[@“Custom_Event_Property_Key1”] = @“Custom_Event_Property_val1";
event.customData[@“Custom_Event_Property_Key2”] = @“Custom_Event_Property_val2";
event.alias = "my custom alias";
[event logEvent];

Android-自定义

new BranchEvent("Some Custom Event")
    .addCustomDataProperty("Custom_Event_Property_Key11", "Custom_Event_Property_val11")
    .addCustomDataProperty("Custom_Event_Property_Key22", "Custom_Event_Property_val22")
    .setCustomerEventAlias("my_custom_alias")
    .logEvent(MainActivity.this);

网络-自定义

var custom_data = {
   "Custom_Event_Property_Key1": "Custom_Event_Property_val1",
   "Custom_Event_Property_Key2": "Custom_Event_Property_val2"
};

branch.logEvent(
    event,
    custom_data,
    callback (err)
);

HTTP API-自定义

终点

POST /v2/event/custom
Content-Type: application/json

参量

关于必需标识符的说明。您必须发送(在user_data中):

developer_identity或
browser_fingerprint_id或
os = iOS AND(idfa或idfv)或
os = Android AND(android_id或aaid)

curl -vvv -d '{
  "name": "picture swiped",
  "customer_event_alias": "my custom alias",
  "user_data": {
    "os": "Android",
    "os_version": 25,
    "environment": "FULL_APP",
    "aaid": "abcdabcd-0123-0123-00f0-000000000000",
    "android_id": "a12300000000",
    "limit_ad_tracking": false,
    "developer_identity": "user123",
    "country": "US",
    "language": "en",
    "ip": "192.168.1.1",
    "local_ip": "192.168.1.2",
    "brand": "LGE",
    "app_version": "1.0.0",
    "model": "Nexus 5X",
    "screen_dpi": 420,
    "screen_height": 1794,
    "screen_width": 1080
  },
  "custom_data": {
    "foo": "bar"
  },
  "metadata": {},
  "branch_key": "key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc"
}' https://api2.branch.io/v2/event/custom

测试事件

为了测试是否在Branch的后端上接收到v2 /事件,请签出 Liveview

更新7 天前

跟踪商务,内容,生命周期和自定义事件


建议的编辑仅限于API参考页

您只能建议对Markdown正文内容进行修改,而不能建议对API规范进行修改。