跳到内容

如何设置事件

事件用于跟踪用户在应用中执行的各种操作。事件数据会按时间顺序存储,从而创建用户行为的时间线。所有关于事件的上下文信息都可以作为一组属性及其值来传递。

一旦正确收集,这些数据可用于:

  • 触发基于行为的消息;
  • 根据用户行为在 Customer Journey 中修改用户沟通流程;
  • 构建在应用中执行特定操作的用户分群;
  • 获取关于用户流程、使用指标和其他统计数据的洞察。

事件类型

Anchor link to

Pushwoosh 中有两种类型的事件:

  • 默认事件
  • 自定义事件

默认事件

Anchor link to

默认事件是用户在应用或网站中执行的基本交互,无论其行业或功能如何。这些关键用户行为构成了客户沟通的核心,并且可以在客户生命周期的任何阶段为任何产品和客户所用。 最新版本的 SDK 中已内置默认事件,除 PW_InAppPurchase 外,无需任何额外设置。

了解更多关于默认事件

自定义事件

Anchor link to

与跨多个应用和行业通用的默认事件不同,自定义事件是您专门为您的应用创建的事件。这些事件跟踪您特定需求的独特操作,例如完成一次锻炼或延长订阅,并帮助您了解用户如何与您的特定功能互动。

自定义事件需要您在自己的端实现。

自定义事件实现

Anchor link to

1. 创建事件并设置属性

Anchor link to

您的应用发送的所有事件必须首先在 Pushwoosh 中创建,并设置好属性及其类型;否则,Pushwoosh 将无法识别它们。

您可以让您的营销团队直接在 Pushwoosh 控制面板中创建事件,或使用 createEvent API 方法。这包括指定事件名称和您想要跟踪的任何相关数据。

2. 调用 /postEvent API

Anchor link to

当您想要跟踪的事件在您的应用中发生时,调用 /postEvent API 将此事件发送到 Pushwoosh。

调用 postEvent 将事件发送到 Pushwoosh:

PWInAppManager.shared().postEvent("eventName", withAttributes: nil)

要添加关于事件的详细信息(参考属性),请按如下方式使用 attributes 参数:

let attributes: [String : Any] = ["AttributedString" : "someString",
"AttributeInt" : 42,
"AttributeList" : [123, 456, "someString"],
"AttributeBool" : true,
"AttributeDate" : NSDate()]
PWInAppManager.shared().postEvent("eventName", withAttributes: attributes)

当事件在您的 Android 应用中发生时,请使用以下说明将此事件发送到 Pushwoosh。

调用 postEvent 将事件发送到 Pushwoosh:

PushwooshInApp.getInstance().postEvent("eventName");

要添加关于事件的详细信息(参考属性),请按如下方式使用 attributes 参数:

TagsBundle attributes = new TagsBundle.Builder()
.putInt("AttributeInt", 17)
.putString("AttributeString", "str")
.putDate("AttributeDate", new Date())
.putBoolean("AttributeBool", true)
.putList("AttributeList", Arrays.asList("item1", "item2", "item3"))
.build();
PushwooshInApp.getInstance().postEvent("eventName", attributes);