目录

Instructions

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 you use marketing attribution for push tasks, register the TASKID parameter in your custom event. For details, please refer to Events.
  • You do not need to set the TASKID, PREPAGEID, and CURRPAGEID parameters for event tracking because they are automatically collected in predefined events.

Procedure

[h2]When Events Have Been Predefined in the SDK

If your event IDs are in the predefined event list HAEventType, perform the following steps:

  1. Import the package of predefined events and that of predefined parameters.
    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
  2. Configure event tracking using the predefined events and parameters. The following example is for reference only:
    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)

[h2]When Events Have Not Been Predefined in the SDK

If your event IDs are not in the predefined event list HAEventType, refer to the following code:
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)