跟踪应用内事件
Singular 可以收集有关应用程序内事件的数据,以帮助分析营销活动的效果并衡量关键绩效指标。例如,您的企业可能希望收集有关用户登录、注册、教程完成或游戏应用中等级提升的数据。
标准事件和属性
Singular 支持各种标准事件。广告网络通常支持这些常用事件,以便进行报告和优化。另一个优点是,当你使用标准事件名称时,Singular 会自动识别并将其添加到事件列表中,而无需手动定义。我们建议尽可能使用标准事件。
发送到 Singular 的事件列表(附带属性)应由用户体验/营销/业务团队根据企业的营销关键绩效指标编制。业务团队可参考《如何跟踪应用内事件》指南:单一归因客户指南》。
您跟踪的每个事件都可以传递各种属性。请参阅每个事件的推荐标准属性。
发送事件
在代码中,使用 eventJSON 或 event 方法向 Singular 发送事件(我们推荐使用 eventJSON 方法,以提高可读性)。
- 对于标准事件,请使用Android SDK 标准事件和属性列表中的事件名称,例如sngTutorialComplete。请参阅下面的代码示例。
- 如果您要发送任何自定义事件(您的组织要测量的事件与 Singular 的标准事件不匹配),请使用符合限制条件的任意字符串。
自定义事件限制:
- 我们强烈建议使用英文传递事件名称和属性,以保证与第三方合作伙伴和分析解决方案(如果您计划使用它们)的兼容性。
- 事件名称限制为 32 个 ASCII 字符。转换为 UTF-8 后,非 ASCII 字符的字符串必须小于 32 字节。
- 属性和值限制为 500 个 ASCII 字符。
Singular.eventJSON 方法
以 JSONObject 格式向 Singular 报告用户事件及附加信息。
签名
Singular.eventJSON(String name, JSONObject args)
使用示例
// Example 1:
// Send the standard event sng_tutorial_complete with the
// recommended standard attributes
JSONObject att = new JSONObject();
try {
att.put(Attributes.sngAttrContent.toString(), "Telugu");
att.put(Attributes.sngAttrContentId.toString(), 32);
att.put(Attributes.sngAttrContentType.toString(), "video");
att.put(Attributes.sngAttrSuccess.toString(), 92);
} catch (JSONException e) {
e.printStackTrace(); // Or log the exception
}
Singular.eventJSON(Events.sngTutorialComplete.toString(), att);
// Example 2:
// Send a custom event named "bonus_points_earned" with custom attributes
JSONObject att = new JSONObject();
try {
att.put("Points", 500);
att.put("score", 650);
} catch (JSONException e) {
e.printStackTrace(); // Or log the exception
}
Singular.eventJSON("Bonus Points Earned", att);
// Example 1:
// Send the standard event sng_tutorial_complete with the
// recommended standard attributes
val att = JSONObject().apply {
put(Attributes.sngAttrContent.toString(), "Telugu")
put(Attributes.sngAttrContentId.toString(), 32)
put(Attributes.sngAttrContentType.toString(), "video")
put(Attributes.sngAttrSuccess.toString(), 75)
}
Singular.eventJSON(Events.sngTutorialComplete.toString(), att)
// Example 2:
// Send a custom event named "bonus_points_earned" with custom attributes
val att = JSONObject().apply {
put("Points", 500)
put("score",650)
}
Singular.eventJSON("Bonus Points Earned", att)
Singular.event 方法
向 Singular 报告一个用户事件,可提供或不提供附加信息。
签名
Singular.event(String eventName)
Singular.event(String eventName, Object... args)
注意: "args "是一个或多个键值对(见下面的示例)。键是字符串,值可以是任何允许作为 JSONObject 值的类型(即 JSONObject、JSONArray、字符串、布尔、整数、长、双或 NULL)。
args "列表必须包含偶数个元素,否则事件将被 Singular 拒绝。
使用示例
// Example 1:
// Send the standard event "Subscribe" (sng_subscribe) without any attributes
Singular.event(Events.sngSubscribe.toString());
// Example 2:
// Send the standard event "sng_tutorial_complete" with the
//recommended standard attributes
Singular.event(Events.sngTutorialComplete.toString(),
Attributes.sngAttrContent.toString(), "Spanish",
Attributes.sngAttrContentId.toString(), 52,
Attributes.sngAttrContentType.toString(), "video",
Attributes.sngAttrSuccess.toString(), 46
);
// Example 3:
// Send a custom event named "SignUp" without any custom attributes
Singular.event("SignUp");
// Example 4:
// Send a custom event named "bonus_points_earned" with a custom attribute
Singular.event("Bonus Points Earned", "Points", 500);
// Example 1:
// Send the standard event "Subscribe" (sng_subscribe) with no attributes
Singular.event(Events.sngSubscribe.toString())
// Example 2:
// Send the standard event sng_tutorial_complete with the
// recommended standard attributes
Singular.event(Events.sngTutorialComplete.toString(),
Attributes.sngAttrContent.toString(), "Telugu",
Attributes.sngAttrContentId.toString(), "32",
Attributes.sngAttrContentType.toString(), "video",
Attributes.sngAttrSuccess.toString(), "yes"
)
// Example 3:
// Send a custom event named "SignUp" with no custom attributes
Singular.event("SignUp")
// Example 4:
// Send a custom event named "bonus_points_earned" with a custom attribute
Singular.event("Bonus Points Earned", "Points", 500)
跟踪应用内收入
Singular 可捕获来自应用内购买(IAP)、订阅和自定义收入的收入事件,以衡量营销活动的绩效和广告支出回报率(ROAS)。收入数据可通过三个主要渠道获得:
- Singular 面板中的交互式报告
- 用于自定义分析的详细导出日志和 ETL 数据目的地
- 实时回传至外部平台
这种全面的收入跟踪功能使您能够根据数据就营销支出和营销活动优化做出决策,同时还能灵活地使用和分析数据。
最佳实践
- Singular 建议使用 Singular 的标准事件和属性命名约定传递事件。
- 如果使用自定义收入事件名称,则应以英文发送,以提高与广告网络回传的兼容性。
- 只有当收入金额大于或小于 0 时,才应向 Singular 发送收入事件。
非订阅应用内购买
要向 Singular 报告收入事件,请将从 Google Billing Library 收到的购买对象传递到收入或自定义收入SDK 方法中。这样做有两个好处:
- Singular 可以获得交易的所有详细信息,从而丰富 Singular 报告。
- Singular 从谷歌获得交易收据,可用于在打击应用内欺诈时验证交易。
注意
- customRevenue允许你传递自定义事件名称,这样你就能在Singular报告中按不同类型的收入事件查看收入。
- 任何以不同货币报告的收入都将自动转换为贵组织首选的货币,具体货币在 Singular 账户中设置。
收入方法
使用购买对象向 Singular 发送收入事件。
签名
Singular.revenue(String currency, double amount, Object purchase)
使用示例
Singular.revenue("USD", 5.50, purchase);
Singular.revenue("USD", 5.50, purchase)
自定义收入方法
使用自定义事件名称和购买对象向 Singular 发送收入事件。
签名
Singular.customRevenue(String eventName, String currency, double amount, Object purchase)
使用示例
Singular.customRevenue("MyCustomRevenue", "USD", 5.50, purchase);
Singular.customRevenue("MyCustomRevenue", "USD", 5.50, purchase)
订阅收入
跟踪订阅:
通过 Singular,您可以在应用程序中跟踪订阅和续订情况,深入了解用户行为和创收情况。查看我们的综合指南,了解如何使用 Singular SDK 实施订阅事件。[订阅事件技术实施指南]
无需购买验证的自定义收入
虽然我们强烈建议按照上述方式报告收入事件,但您也可以使用收入和自定义收入而不传递购买对象。相反,您可以传递交易的货币和金额,以及可选的产品详细信息。
customRevenue方法还允许传递自定义事件名称。
请注意,如果使用这些方法,Singular 不会获得交易收据,也无法验证交易。
收入方法
向 Singular 发送包含收入金额、货币和可选详细信息的收入事件。
签名
Singular.revenue(String currency, double amount)
Singular.revenue(String currency, double amount, String productSKU, String productName, String productCategory, int productQuantity, double productPrice)
Singular.revenue(String currency, double amount, Map<String, Object> attributes)
使用示例
无产品详细信息
Singular.revenue("USD", 5.50);
有产品详细信息
Singular.revenue("EUR", 5.00, "SKU1928375", "Reservation Fee", "Fee" , 1, 5.00);
在属性图中包含产品详细信息
Map<string, object="Object"> attributes = new HashMap<>();
attributes.put("product_id", "com.app.premium");
attributes.put("transaction_id", "T12345");
attributes.put("quantity", 1);
attributes.put("is_trial", false);
// Call the revenue method
Singular.revenue("USD", 9.99, attributes);
无产品详细信息
Singular.revenue("USD", 5.50)
有产品详细信息
Singular.revenue("EUR", 5.00, "SKU1928375", "Reservation Fee", "Fee" , 1, 5.00)
在属性图中包含产品详细信息
val attributes = mutableMapOf<String, Any>().apply {
put("product_id", "com.app.premium")
put("transaction_id", "T12345")
put("quantity", 1)
put("is_trial", false)
}
// Call the revenue method
Singular.revenue("USD", 9.99, attributes)
自定义收入方法
通过指定事件名称、收入金额、货币代码和任何其他交易属性,向 Singular 发送自定义收入事件。Singular 会处理这些事件以跟踪应用程序内的收入。
签名
Singular.customRevenue(String eventName, String currency, double amount)
Singular.customRevenue(String eventName, String currency, double amount, String productSKU, String productName, String productCategory, int productQuantity, double productPrice)
Singular.customRevenue(String eventName, String currency, double amount, Map<String, Object> attributes)
使用示例
无产品详细信息
Singular.customRevenue("MyCustomRevenue", "USD", 5.50);
有产品详细信息
Singular.customRevenue("MyCustomRevenue", "EUR", 5.00, "SKU1928375", "Reservation Fee", "Fee" , 1, 5.00);
属性图中有产品详细信息
Map<string, object="Object"> attributes = new HashMap<>();
attributes.put("product_id", "com.app.premium");
attributes.put("transaction_id", "T12345");
attributes.put("quantity", 1);
attributes.put("is_trial", false);
// Call the revenue method
Singular.customRevenue("MyCustomRevenue", "USD", 9.99, attributes);
无产品详细信息
Singular.customRevenue("MyCustomRevenue", "USD", 5.50)
有产品详细信息
Singular.customRevenue("MyCustomRevenue", "EUR", 5.00, "SKU1928375", "Reservation Fee", "Fee" , 1, 5.00)
属性图中有产品详细信息
val attributes = mutableMapOf<String, Any>().apply {
put("product_id", "com.app.premium")
put("transaction_id", "T12345")
put("quantity", 1)
put("is_trial", false)
}
// Call the revenue method
Singular.customRevenue("MyCustomRevenue", "USD", 9.99, attributes)
混合事件跟踪(高级)
Singular 建议通过集成到应用程序中的 Singular SDK 发送所有事件和收入。不过,Singular 也可以从其他来源收集事件和收入。
任何未从 Singular SDK 发送的事件都必须符合 Singular 的服务器到服务器事件文档要求,并提供匹配的设备标识符,以便正确归属事件。
重要:
如果服务器到服务器事件请求中使用的设备标识符在 Singular 中没有匹配的设备标识符,就会出现差异。请注意以下可能性:
- 如果事件请求是在 Singular SDK 从应用程序会话记录设备标识符之前收到的,那么该事件请求将被视为未知设备的 "第一次会话",Singular 将把该设备作为有机归属。
- 如果 Singular SDK 确实记录了设备标识符,但 Singular SDK 标识符与服务器到服务器事件请求中指定的设备标识符不同,那么事件将被错误归属。
混合事件跟踪指南
从内部服务器发送事件
Singular可以收集来自服务器的收入数据,帮助分析营销活动的表现和投资回报率。
要求
- 从应用程序内的注册或登录事件中捕获并传递设备标识符,并将此数据与服务器上的用户 ID 一起存储。由于用户的设备标识符可能会发生变化,因此请确保在用户生成应用程序会话时更新标识符。这将确保服务器端事件归属于正确的设备。
- 服务器端事件是平台特定的,只能使用与设备平台相匹配的设备标识符发送(如 iOS 设备的 IDFA 或 IDFV)。
- 您可以使用 Singular 内部 BI 回传机制将事件实时推送到内部端点,以便更新服务器端的数据集。请参阅内部 BI 回传常见问题。
- 查看服务器到服务器集成指南中的"跟踪收入 "部分,了解详情。
从收入提供商发送事件
第三方提供商(如RevenueCat或adapty)可以向 Singular 提供购买和订阅收入。
请点击以下链接了解如何启用这些合作伙伴。
从Segment发送事件
要使Segment与Singular SDK同时向Singular发送事件,您必须在Segment中添加一个"云模式 "目的地。请点击此处查看我们的指南。