If your app server collects some user behavior data that is not reported by the app, and if you want to apply the data to the analysis reports provided by Analytics Kit, you can call this API on the app server to synchronize the user behavior data from the app server to Analytics Kit. This API does not take effect without the Analytics SDK. It only reports data that cannot be reported by the Analytics SDK.
Protocol | HTTPS POST |
|---|---|
Direction | Your callback API server -> Analytics Kit server |
URL | {rootUrl}/analytics/datacollection/import/event NOTE: For details about {rootUrl}, please refer to API Access Address. |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Request header
Parameter | Mandatory | Type | Description |
|---|---|---|---|
x-product-id | Yes | String | Product ID registered in AppGallery Connect. |
x-app-id | Yes | String | App ID registered in AppGallery Connect. |
Authorization | Yes | String | Authentication information. For details, please refer to OAuth 2.0-based Authentication. NOTE: A space character must be added between Bearer and the value of access_token. |
Request body
Parameter | Mandatory | Type | Description |
|---|---|---|---|
data_type | Yes | Integer | Data type, indicating whether the data is related to user behavior. This parameter has a fixed value of 3. |
protocol_version | Yes | String | Protocol version. This parameter has a fixed value of 1. |
productid | Yes | String | Product ID registered in AppGallery Connect. |
appid | Yes | String | App ID registered in AppGallery Connect. |
package_name | Yes | String | App package name. For a web app, set this parameter to the value of appid. |
requestid | Yes | String | 32-character hexadecimal code generated randomly for each request during data reporting. |
timestamp | Yes | Long | Event reporting time. The value is the total number of milliseconds since 1970-01-01 00:00:00. |
event_set | Yes | json | Event information. |
event_set parameters
Parameter | Mandatory | Type | Description |
|---|---|---|---|
aaid | Yes | String | Anonymous user ID, which is obtained through getAAID on the device side. |
userid | No | String | User ID. |
oaid | No | String | Open advertising ID. For iOS devices, the IDFA is used. For Android devices, the OAID is used preferentially. If the OAID cannot be obtained, the GAID will be used. |
oaid_source | No | String | OAID source. The options are as follows:
|
_oaid_tracking_flag | No | boolean | Indicates whether ad tracking is allowed. The value true indicates that ad tracking is allowed (Disable personalized ads is turned off), and the value false indicates that ad tracking is not allowed (Disable personalized ads is turned on). |
eventid | Yes | String | Event ID. |
eventtime | Yes | Long | Event occurrence time. The value is the total number of milliseconds since 1970-01-01 00:00:00. |
event_session_name | Yes | String | Event session ID |
first_session_event | No | String | Indicates whether an event session has been updated. |
properties | No | JSON | Event parameters. |
POST /analytics/datacollection/import/event HTTP/1.1
Content-Type: application/json; charset=UTF-8
Content-Length: xxxx
Accept: application/json
Authorization: Bearer 78C2395236BBF4262CAE4F1172E327C2929AD63EAA0395961A49DEBC3B6F8339
x-product-id: sample-productid
x-app-id: sample-appid
{
"data_type":3,
"protocol_version":"1",
"requestid":"083e920d3f2b4f6aaa2ffba348e58d75",
"timestamp":1624435942860,
"appid":"101282071",
"productid":"98433080309583386",
"package_name":"com.huawei.test",
"event_set":[
{
"aaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"userid":"",
"oaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"oaid_source":"oaid",
"_oaid_tracking_flag":"true",
"pushtoken":"",
"eventtime":1587867045291,
"event_session_name":"e508bb99af7f41f5b1573690a0987b88_1587866781700",
"eventid":"$EnterScreen",
"first_session_event":"true",
"properties":{
"$PrevActivityName":"",
"$PrevActivityId":"",
"$CurActivityName":"https://localhost:30401/",
"$CurActivityId":"https://localhost:30401/"
}
},
{
"aaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"userid":"",
"oaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"oaid_source":"oaid",
"_oaid_tracking_flag":"true",
"androidid":"",
"pushtoken":"",
"eventtime":1587867045292,
"event_session_name":"e508bb99af7f41f5b1573690a0987b88_1587866781701",
"eventid":"notification_received",
"first_session_event":"false",
"properties":{
"exam_level":"1-1",
"exam_difficulty":"high",
"exam_price":39
}
},
{
"aaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"userid":"",
"oaid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"oaid_source":"oaid",
"_oaid_tracking_flag":"true",
"androidid":"",
"pushtoken":"",
"eventtime":1587867045291,
"event_session_name":"e508bb99af7f41f5b1573690a0987b88_1587866781700",
"eventid":"$EnterScreen",
"first_session_event":"true",
"properties":{
"$PrevActivityName":"",
"$PrevActivityId":"",
"$CurActivityName":"https://localhost:30401/",
"$CurActivityId":"https://localhost:30401/"
}
}
]
} Assume that the status code is 200.
Response header
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Content-Type | Yes | application/json | Response data format. |
Response body
Parameter | Mandatory | Type | Description |
|---|---|---|---|
result_code | Yes | String | Result code. For details, please refer to Result Codes. |
result_msg | Yes | String | Response description. |
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Connection: Close
Content-Length: xxxx
{
"result_code":"0",
"result_msg":"success"
}