Report User Event API
In the Operation Growth platform, user behavior meta events record key information such as when, in what environment, what behavior the user performed, how they performed it, and why they performed it.
User behaviors are stored and recorded as meta events. As objective factual data, user behavior meta events cannot be deleted or changed once reported successfully. With the API below, you can report user events.
Reporting user events must be based on CUID, and the event must already exist in the data center of the Operation Growth platform.
Request Method
POST
Request URL
POST https://growth.jiguang.cn/smartop/api/v1/events/report
QPS Limit
QPS <= 100
Request Headers
> Content-Type: application/json
> Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==
Request Body Parameters
The API supports single-record reporting and batch reporting. For batch reporting, the number of request records must be <= 100.
In real business scenarios, do not include comments. The comments in the following example are only to help developers understand parameter meanings.
{
"appKey": "96441e4d73207a6517abfbbc", // appKey generated by the system for the API data source
"data": [
{
"cuid": 10000091198, // User identity ID of the user who performed this behavior event
"eventName": "jg_app_viewscreen", // Field name of the custom event, unique in the project
"itime": 1654076420772, // Specific timestamp when the custom event occurred
"randomId": "5b102148-0d28-4a6a-8658-483f7d1c735e", // Event reporting ID
"properties": { // Event attributes
"propertyA": "a", // Event attribute field name: attribute value
"propertyB": 2
}
},
{
"cuid": 10000091199, // User identity ID of the user who performed this behavior event
"eventName": "fllow_wechat", // Field name of the custom event, unique in the project
"itime": 1654076420235, // Specific timestamp when the custom event occurred
"properties": { // Event attributes
"propertyC": "a", // string type event attribute
"propertyD": 3, // number type event attribute
"propertyJ": "true"/"false" 或者 "0"/"1", // bool type event attribute
"propertyK": 1698168389000, // datetime type event attribute, 13-digit timestamp
"propertyL": ["test1","20231025"], // list type event attribute
}
}
]
}
| Field | Type | Required | Description |
|---|---|---|---|
| appKey | String | Yes | appKey generated by Project -> Data Source Management -> API Data Source |
| data | Array | Yes | Behavior event list |
| cuid | Long | Yes | Unique user ID of the user who performed the behavior event |
| eventName | String | Yes | Event name of the custom event in the project |
| itime | Long | Yes | Specific timestamp when the behavior event occurred |
| randomId | String | No | Event reporting ID used to verify event uniqueness. If this field is not filled in, the Operation Growth platform automatically generates it. |
| properties | JSON Object | No | Event attributes. The key is the attribute name, and the value is the attribute value. |
- When the project id, appKey, itime, cuid, and randomId of an event are all the same, it is considered the same event report, and the Operation Growth platform performs deduplication. Deduplication is offline calculation, with a delay of no more than 3 days.
- Different meta events are associated with different event attribute parameters. Developers are advised to view the attribute list associated with the target meta event first, then configure corresponding attribute values.
- Reported attributes and attribute values outside the associated range of the meta event are ignored.
- During batch reporting, if any record has an error, the entire batch of reported events fails.
Response Parameters
- N/A. HTTP code 200 indicates successful reporting.
| Field | Type | Required | Description |
|---|---|---|---|
| code | Int | Yes | Whether the API call succeeded. 0 indicates success, and other values indicate an error. 4000 indicates multiple errors, which must be viewed in data. |
| msg | String | Yes | API call result description, with a text explanation of the error code. |
| data | Array | No | Error code list for reported events |
| code | Int | Yes | Error code for reported event |
| msg | String | Yes | Text description of the error code |
Successful Response
{
"code": 0,
"msg": "ok"
}
Failed Response
Single error response:
{
"code": 4100,
"msg": "appKey 或者项目 id 无效"
}
Multiple error response:
{
"code": 4000,
"msg": "请求有多个错误,请在data中查看错误码列表",
"data": [
{
"code": 4104,
"msg": "itime 1676875 时间戳超出合理范围"
},
{
"code": 4104,
"msg": "itime 1676875 时间戳超出合理范围"
}
]
}
Error Codes
| Error Code | Description | Solution |
|---|---|---|
| 4000 | Request has multiple errors | View the error code list in data. |
| 4001 | xxx field type error | Confirm whether the type of the xxx field is correct. |
| 4002 | xxx field array size exceeds the range | Confirm whether the size of the xxx field array exceeds the limit. |
| 4003 | xxx field length exceeds the range | Confirm whether the type of the xxx field is correct. |
| 4004 | xxx field cannot be empty | Confirm whether the xxx field has a value. |
| 4100 | Invalid appKey | View the appkey of the HTTP API data source on the data source page, and check whether it is consistent with the appKey in the request body and whether it belongs to the current requested project. |
| 4101 | Event xxx does not exist | Check whether the xxx event name is correct. |
| 4102 | Attribute xxx of event xxx does not exist or is disabled | Check the xxx event attribute. |
| 4103 | User corresponding to cuid xxx does not exist | Check whether the cuid is correct. |
| 4104 | itime xxx timestamp is outside the reasonable range | The itime timestamp should be a millisecond value. If it is greater than current time + 5 minutes or earlier than one year ago, it is considered invalid. |
| 4105 | xxx attribute value type should be xxx | Check whether the passed attribute value type is correct. |