Some events have been predefined by the Analytics SDK based on common use cases. It is recommended that you use predefined event IDs for event tracking and analysis. The system provides various insight reports based on predefined events.
Predefined events and parameters are reserved for Analytics Kit. The ID of a custom event cannot be the same as that of a predefined event. Otherwise, the custom event will be identified as a predefined event.
For details about the ID constants of predefined events and parameters, please refer to HAEventType and HAParamType, respectively.
After configuring event tracking, you need to register predefined events and related parameters in AppGallery Connect. For details, please refer to Events. When an event is triggered, you can view the analysis report on the Real-time overview page.
If your event IDs are in the predefined event list HAEventType, perform the following steps:
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)