Analytics Kit predefines rich analysis models to help you easily
understand user behavior and gain in-depth insights into users,
products, and content. As such, you can carry out data-driven
operations and make informed decisions about app marketing and product
optimization.
Analytics Kit implements the following functions
using data collected from apps:
In this codelab, you will create a demo app based on the provided demo project. After creating a demo app, you will be able to:
In this codelab, you will learn how to:
To integrate Analytics Kit, you must complete the following preparations:
In this section, you will try to build a demo with the question answering function to learn how to use the main APIs of Analytics Kit. We have prepared the code for you, meaning you only need to follow the instructions in each step below to learn how to use Analytics Kit to report the events you are interested in, such as answering questions, calculating scores, and setting user attributes.
Your app is so far loaded with the required functions. Next, you will use Analytics Kit to report the events that interest you.
npm install –save @hw-hmscore/analytics-sdk-quickapp
// TODO: Import necessary modules.
import agconnect from "@agconnect/api";
import "@agconnect/instance";
import "@hw-hmscore/analytics-sdk-quickapp";
// TODO: Initialize the Analytics Kit.
var agConnectConfig = {};
agconnect.instance().configInstance(agConnectConfig);
// app.ux
module.exports = {
onCreate() {
this.$agconnect = agconnect;
this.$hiAnalytics = agconnect.analytics();
}
};
reportAnswer(answer) {
let answerTime = this.formatDate();
let reportMessage = {
question: this.questions[this.currentNumber],
answer: answer,
answerTime: answerTime
};
this.$app.$hiAnalytics.onEvent("Answer", reportMessage);
}
postScore() {
let scoreMessage = {};
scoreMessage[this.$app.$agconnect.analytics.ParamName.SCORE] = this.totalScore;
this.$app.$hiAnalytics.onEvent(this.$app.$agconnect.analytics.EventName.SUBMITSCORE, scoreMessage);
}
save() {
this.sport && this.$app.$hiAnalytics.setUserProfile("favor_sport", this.sport);
}
onHide() {
this.$app.$hiAnalytics.pageEnd("/Settings");
},
onShow() {
this.$app.$hiAnalytics.pageStart("/Settings");
}
For details about APIs, please refer to the Analytics Kit API Reference.
Perform initialization at the beginning of the onCreate method in the app.ux file.
You can only view some analysis results on the Real-time overview page. Analysis results on other pages such as Event analysis and Launch analysis are available the day after the corresponding data is processed.
Well done. You have successfully completed this codelab and learned how to:
For more information, please click the following link:
Related documents
To download the sample code, please click the button below: