HUAWEI Analytics Kit is based on the event analytics data model.
The analytics data model uses the Event-Param-User model to record data, describes events using parameters, and describes the characteristics of users.
Term | Meaning | Description |
Event | Event | An event describes a specific task completed by a user at a location using a method at a time, including key elements such as who, when, where, how, and what. |
Param | Parameter | Associated parameters reported in events, for example, the product name and product price parameters in the event of a product being added to the shopping cart. These parameters can be used for subsequent in-depth analytics. |
UserProfiles | User attribute | List of user attributes. Common user attributes include the ODID, device model, app version, and custom user attributes such as food preferences. |
HUAWEI Analytics Kit collects the AAID that is allocated by the HMS Instance ID to each app instance installed on the device. The AAID is used for connecting various Huawei services, such as HUAWEI PUSH Kit, HUAWEI Analytics Kit, and remote configurations.
The AAID will be reset in the following scenarios:
The user uninstalls or reinstalls the app.
The user restores the device to its factory settings.
The user clears the app data.
The app calls the clearCachedData API.
1. Initialize the HMS Core Analytics SDK by calling the getInstance API.
- HiAnalyticsInstance instance = HiAnalytics.getInstance(context);
2. Record defined events using the onEvent API. For definitions of the events, please refer to Event Description.
3. Call APIs of HUAWEI Analytics Kit to implement the corresponding functions. For details, please refer to API Reference. For example, call the setUserProfile API to set user attributes.
1. After the agconnect-services.json file is imported successfully, initialize HUAWEI Analytics Kit in the onCreate method of the first activity to obtain an instance of HUAWEI Analytics Kit. If the agconnect-services.json file is incorrect, data cannot be collected at specified tracing points.
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- //Enable SDK log recording.
- HiAnalyticsTools.enableLog();
- HiAnalyticsInstance instance = HiAnalytics.getInstance(this);
- //Or, use context initialization.
- // Context context = this.getApplicationContext();
- // HiAnalyticsInstance instance = HiAnalytics.getInstance(context);
- // instance.setUserProfile("userKey","value")
- }
2. Insert tracing points in proper position of the code.
- //Customize tracing points and add tracing points in the proper position of the code.
- Bundle bundle = new Bundle();
- bundle.putString("exam_difficulty","high");
- bundle.putString("exam_level","1-1");
- bundle.putString("exam_time","20190520-08");
- instance.onEvent("begin_examination", bundle);
- //Add tracing points for predefined events.
- Bundle bundle_pre = new Bundle();
- bundle_pre.putString(PRODUCTID, "item_ID");
- bundle_pre.putString(PRODUCTNAME, "name");
- bundle_pre.putString(CATEGORY, "category");
- bundle_pre.putLong(QUANTITY, 100L);
- bundle_pre.putDouble(PRICE, 10.01);
- bundle_pre.putDouble(REVENUE, 10);
- bundle_pre.putString(CURRNAME, "currency");
- bundle_pre.putString(PLACEID, "location_ID");
- instance.onEvent(ADDPRODUCT2WISHLIST, bundle_pre);
During the development, you can enable the debug mode to view the event records in real time, observe the results, and adjust the event tracing scheme.
1. Run the following command to enable the debug mode on an Android device:
- adb shell setprop debug.huawei.hms.analytics.app package_name
After the debug mode is enabled, all events will be reported in real time.
2. Run the following command to disable the debug mode:
- adb shell setprop debug.huawei.hms.analytics.app .none.
Successfully reported data is displayed on Huawei Developers in real time, as shown in the figure below.

For details about how to view analysis data on Huawei Developers, please refer to App Debugging.