根据常用的使用场景,Analytics SDK预先定义了部分事件ID,推荐优先使用预定义常量进行埋点和分析,系统基于预置事件提供了丰富的洞察报告。
预置事件和参数是Analytics Kit的保留字段,自定义事件的事件ID不能与预置事件的ID重复,否则会被识别为预置事件。
预置事件的ID常量请参见HAEventType、参数ID常量请参见HAParamType。
埋点后,您需要到分析控制台去注册预置事件及相关参数,注册方法请参见事件管理。当用户触发相应的事件时,您可在控制台实时概览界面查看可视化分析数据的报告。
如果您的事件ID已在预置事件列表HAEventType中,请参考如下步骤进行埋点:
“Java”
import com.huawei.hms.analytics.type.HAEventType;
import com.huawei.hms.analytics.type.HAParamType; “Kotlin”
import com.huawei.hms.analytics.type.HAEventType
import com.huawei.hms.analytics.type.HAParamType “Java”
Bundle bundle_pre = new Bundle();
bundle_pre.putString(HAParamType.PRODUCTID, "item_ID");
bundle_pre.putString(HAParamType.PRODUCTNAME, "name");
bundle_pre.putString(HAParamType.CATEGORY, "category");
bundle_pre.putLong(HAParamType.QUANTITY, 100L);
bundle_pre.putDouble(HAParamType.PRICE, 10.01);
bundle_pre.putDouble(HAParamType.REVENUE, 10);
bundle_pre.putString(HAParamType.CURRNAME, "currency");
bundle_pre.putString(HAParamType.PLACEID, "location_ID");
instance.onEvent(HAEventType.ADDPRODUCT2WISHLIST, bundle_pre); “Kotlin”
val bundle_pre = Bundle()
bundle_pre.putString(HAParamType.PRODUCTID, "item_ID")
bundle_pre.putString(HAParamType.PRODUCTNAME, "name")
bundle_pre.putString(HAParamType.CATEGORY, "category")
bundle_pre.putLong(HAParamType.QUANTITY, 100L)
bundle_pre.putDouble(HAParamType.PRICE, 10.01)
bundle_pre.putDouble(HAParamType.REVENUE, 10.0)
bundle_pre.putString(HAParamType.CURRNAME, "currency")
bundle_pre.putString(HAParamType.PLACEID, "location_ID")
instance.onEvent(HAEventType.ADDPRODUCT2WISHLIST, bundle_pre) “Java”
Bundle bundle = new Bundle();
bundle.putString("$LotteryName", "name");
bundle.putString("$LotteryType", "123");
instance.onEvent("$Lottery", bundle); “Kotlin”
val bundle = Bundle()
bundle.putString("$LotteryName", "name")
bundle.putString("$LotteryType", "123")
instance.onEvent("$Lottery", bundle)