Retention Analysis model API
For how to call the API, see the calling method described in the Open API document.
To learn about usage scenarios, read Retention Analysis in the User Guide.
1. Retention Analysis query
Endpoint URL
/open/retention-analyze?token=xxx
Request method
POST
Content-Type
application/json
Request query parameters
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| token | xxx | String | Yes | Query key |
Request body parameters
{
"eventView":{
"endTime":"2021-10-30 23:59:59",
"filts":[
{
"columnDesc":"App version",
"columnName":"app_version",
"comparator":"equal",
"filterType":"SIMPLE",
"ftv":[
"V1.0"],
"specifiedClusterDate":"2022-01-24",
"tableType":"event",
"timeUnit":""
}],
"firstDayOfWeek":1,
"groupBy":[
{
"columnDesc":"Browser",
"columnName":"browser",
"propertyRange":"",
"specifiedClusterDate":"2022-01-24",
"tableType":"event"
}],
"recentDay":"",
"relation":"and",
"startTime":"2021-10-01 00:00:00",
"statType":"retention",
"taIdMeasureVo":{
"columnDesc":"User Unique ID",
"columnName":"#user_id",
"tableType":"event"
},
"timeParticleSize":"week",
"unitNum":1
},
"events":[
{
"eventName":"login",
"eventNameDisplay":"",
"filts":[
{
"columnDesc":"app_version",
"columnName":"app_version",
"comparator":"equal",
"filterType":"SIMPLE",
"ftv":["V1.0"],
"specifiedClusterDate":"2022-01-26",
"tableType":"event",
"timeUnit":""
}],
"relation":"and",
"relationUser":"and",
"type":"first"
},
{
"eventName":"logout",
"eventNameDisplay":"",
"filts":[
],
"relation":"and",
"relationUser":"and",
"type":"second"
},
{
"analysis":"TOTAL_TIMES",
"analysisDesc":"Event total",
"eventName":"activity_attend",
"eventNameDisplay":"",
"filts":[
],
"quota":"",
"relation":"and",
"relationUser":"and",
"type":"simultaneous_display"
}],
"projectId": 377,
"limit": 2,
"timeoutSeconds": 10,
"useCache": true,
"zoneOffset": 10
}
Request parameters
| $$Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| eventView | - | Object | Yes | Common properties of the metrics |
| eventView.endTime | 2021-10-30 23:59:59 | String | No | End time (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative time is empty |
| eventView.filts | - | List | No | Global filters |
| eventView.filts.columnDesc | App version | String | No | Field display name |
| eventView.filts.columnName | app_version | String | Yes | Field name |
| eventView.filts.comparator | equal | String | Yes | See Filter expressions in the Query API |
| eventView.filts.filterType | SIMPLE | String | No | Filter mode. SIMPLE: simple, COMPOUND: compound |
| eventView.filts.ftv | ["V1.0"] | List | No | Literal constants used as boundaries for property comparison |
| eventView.filts.specifiedClusterDate | 2022-01-24 | String | No | Uses the historical version of the tag for the specified date |
| eventView.filts.tableType | event | String | Yes | Table type enum values |
| eventView.filts.timeUnit | String | No | Unit of the property comparison value, valid only for relativeEvent*: day, hour, minute | |
| eventView.firstDayOfWeek | 1 | Integer | No | When timeParticleSize is week, specifies the first day of the week. 1: Monday, 2: Tuesday, .., 7: Sunday. Minimum 1, maximum 7 |
| eventView.groupBy | - | List | No | Group-by properties. There can be zero or more |
| eventView.groupBy.columnDesc | Browser | String | No | Field display name |
| eventView.groupBy.columnName | browser | String | Yes | Field name |
| eventView.groupBy.propertyRange | String | No | Custom property range | |
| eventView.groupBy.specifiedClusterDate | 2022-01-24 | String | No | Uses the historical version of the tag for the specified date |
| eventView.groupBy.tableType | event | String | Yes | Table type enum values |
| eventView.recentDay | String | No | Relative time (this item, the start time, and the end time can't all be empty) | |
| eventView.relation | and | String | No | Logical relation. and: logical AND, or: logical OR |
| eventView.startTime | 2021-10-01 00:00:00 | String | No | Start time (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative time is empty |
| eventView.statType | retention | String | Yes | Statistics type. retention: retention; lost: churn |
| eventView.taIdMeasureVo | - | Object | No | Analysis entity configuration |
| eventView.taIdMeasureVo.columnDesc | User Unique ID | String | No | Field display name |
| eventView.taIdMeasureVo.columnName | #user_id | String | Yes | Field name |
| eventView.taIdMeasureVo.tableType | event | String | Yes | Table type enum values |
eventView.timeParticleSize | week | String | Yes | Time unit of the analysis
|
| eventView.unitNum | 1 | Integer | Yes | Retention period |
| events | - | List | Yes | List of event metrics |
| events.eventName | login | String | Yes | Event name of the metric. You can use anyEvent to represent any event |
| events.eventNameDisplay | String | No | Display name of the custom metric | |
| events.analysis | TRIG_USER_NUM | String | No | Analysis type (aggregation operation). For details, see Retention Also Show aggregation type enum values |
| events.analysisDesc | Event total | String | No | Description of the analysis type |
| events.quota | String | No | Metric property (used with analysis to specify which analysis type of which property) | |
| events.filts | - | List | No | List of conditions |
| events.filts.columnDesc | app_version | String | No | Field display name |
| events.filts.columnName | app_version | String | Yes | Field name |
| events.filts.comparator | equal | String | Yes | See Filter expressions in the Query API |
| events.filts.filterType | SIMPLE | String | No | Filter mode. SIMPLE: simple, COMPOUND: compound |
| events.filts.ftv | ["V1.0"] | List | No | Literal constants used as boundaries for property comparison |
| events.filts.specifiedClusterDate | 2022-01-26 | String | No | Uses the historical version of the tag for the specified date |
| events.filts.tableType | event | String | Yes | Table type enum values |
| events.filts.timeUnit | String | No | Time unit of the filter | |
| events.relation | and | String | No | Logical relation. and: logical AND, or: logical OR |
| events.relationUser | and | String | No | Logical relation of user filters. and: logical AND, or: logical OR |
events.type | first | String | Yes | Retention event type:
|
| projectId | 377 | Integer | Yes | Project ID |
| limit | 2 | Integer | No | Maximum number of groups per analysis object. Optional. Defaults to 1000, with a maximum of 10000 |
| timeoutSeconds | 10 | Integer | No | Request timeout. The query task is canceled when it times out |
| useCache | true | Boolean | Yes | true means the cache is used |
| zoneOffset | 10 | Integer | No | Time zone |
Success response example
{
"data": {
"result_generate_time": "2022-01-01 00:00:00",
"state_avg": {
"0": [
{
"groupCols": [
"Overall"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"0.998"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"0.9981"
]
}
],
"1": [
{
"groupCols": [
"Overall"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"1"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"1"
]
}
],
"2": [
{
"groupCols": [
"Overall"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [],
"values": [
"-",
"132405.4"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [],
"values": [
"-",
"66343.2"
]
}
]
},
"x": [
"2021-09-27",
"2021-10-04",
"2021-10-11",
"2021-10-18",
"2021-10-25"
],
"y": {
"0": {
"2021-09-27": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"7388",
"7374"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"3647",
"3642"
]
}
],
"2021-10-04": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"7861",
"7844"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"3939",
"3930"
]
}
],
"2021-10-11": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"8013",
"7994"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"4062",
"4054"
]
}
],
"2021-10-18": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"8553",
"8543"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"4225",
"4218"
]
}
],
"2021-10-25": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7414,
"isTotal": 1,
"values": [
"7414",
"7397"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3741,
"isTotal": 0,
"values": [
"3741",
"3733"
]
}
]
},
"1": {
"2021-09-27": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"7388",
"7388"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"3647",
"3647"
]
}
],
"2021-10-04": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"7861",
"7861"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"3939",
"3939"
]
}
],
"2021-10-11": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"8013",
"8013"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"4062",
"4062"
]
}
],
"2021-10-18": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"8553",
"8553"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"4225",
"4225"
]
}
],
"2021-10-25": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7414,
"isTotal": 1,
"values": [
"7414",
"7414"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3741,
"isTotal": 0,
"values": [
"3741",
"3741"
]
}
]
},
"2": {
"2021-09-27": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"0",
"125324"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"0",
"62105"
]
}
],
"2021-10-04": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"0",
"132130"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"0",
"65971"
]
}
],
"2021-10-11": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"0",
"134691"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"0",
"68566"
]
}
],
"2021-10-18": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"0",
"144030"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"0",
"71345"
]
}
],
"2021-10-25": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7414,
"isTotal": 1,
"values": [
"0",
"125852"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3741,
"isTotal": 0,
"values": [
"0",
"63729"
]
}
]
}
},
"z": [
"login",
"logout",
"activity_attend"
]
},
"return_code": 0,
"return_message": "success"
}
Response parameters
| $$Parameter name | Example value | Parameter type | Description |
|---|---|---|---|
| return_code | 0 | Integer | Return code |
| return_message | success | String | Return message |
| data | - | Object | Returned result |
| data.result_generate_time | 2022-01-01 00:00:00 | String | Result generation time |
| data.state_avg | - | Object | Result map. The key is type, and the value is the retention groups |
| data.state_avg.{type} | - | List | Value of type. 0: retention; 1: churn; 2: Also Show metric |
| data.state_avg.{type}.groupCols | ["Overall"] | List | Group columns |
| data.state_avg.{type}.initNum | 0 | Integer | Initial value |
| data.state_avg.{type}.isTotal | 1 | Integer | Whether it's the total. 1: yes; 0: no |
| data.state_avg.{type}.lastValidDateVerticalIndexs | ["-", "4"] | List | Index of the last date with complete data |
| data.state_avg.{type}.values | ["-", "0.998"] | List | Value list: "-" or a number |
| data.x | ["2021-09-27"] | List | Date list |
| data.y | - | Object | Y-axis data |
| data.y.{type} | - | Object | Value of type. 0: retention; 1: churn; 2: statistics |
| data.y.{type}.{date} | - | List | The key is the date |
| data.y.{type}.{date}.groupCols | ["Overall"] | List | Group columns |
| data.y.{type}.{date}.includeToday | false | Boolean | Whether today is included |
| data.y.{type}.{date}.initNum | 7388 | Integer | Initial value |
| data.y.{type}.{date}.isTotal | 1 | Integer | Whether it's the total. 1: yes; 0: no |
| data.y.{type}.{date}.values | ["7388"] | List | Value list |
| data.z | ["login"] | List | Event name list |
Error response example
{
"return_code": -1008,
"return_message": "Parameter (token) is empty"
}
| Parameter name | Example value | Parameter type | Description |
|---|---|---|---|
| return_code | -1008 | Integer | Return code |
| return_message | Parameter (token) is empty | String | Return message |
2. Retention Analysis full download
Endpoint URL
/open/streaming-download/retention-analyze?token=xxx
Request method
POST
Content-Type
application/json
Request query parameters
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| token | xxx | String | Yes | Query key |
Request body parameters
{
"eventView": {
"collectFirstDay": 1,
"endTime": "2022-03-08 16:55:10",
"filts": [],
"groupBy": [{
"columnDesc": "Channel",
"columnName": "channel",
"propertyRange": "",
"specifiedClusterDate": "2022-03-09",
"tableType": "event"
}],
"recentDay": "1-7",
"relation": "and",
"startTime": "2022-03-02 16:55:10",
"statType": "retention",
"taIdMeasureVo": {
"columnDesc": "User Unique ID",
"columnName": "#user_id",
"tableType": "event"
},
"timeParticleSize": "day",
"unitNum": 7
},
"events": [{
"eventName": "Recharge",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "first"
}],
"projectId": 390
}
Request parameters
| $$Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| eventView | - | Object | Yes | Same as the parameters of the Retention Analysis query API |
| events | - | List | Yes | Same as the parameters of the Retention Analysis query API |
| projectId | 377 | Integer | Yes | Project ID |
| zoneOffset | 10 | Integer | No | Time zone |
Response
Same as the Retention Analysis full download in AE
3. Retention Analysis user list
Endpoint URL
/open/retention-user-list?token=xxx
Request method
POST
Content-Type
application/json
Request query parameters
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| token | xxx | String | Yes | Query key |
Request body parameters
{
"projectId": 0,
"eventView": {
"startTime": "2019-11-24 00:00:00",
"endTime": "2019-11-26 00:00:00",
"recentDay": "1-3",
"statType": "retention",
"timeParticleSize": "day",
"unitNum": 7,
"groupBy": [
{
"columnName": "#province",
"tableType": "event"
}
]
},
"events": [
{
"type": "first",
"relation": "and",
"eventName": "player_register",
"filts": [
{
"columnName": "#province",
"comparator": "equal",
"ftv": [
"Jiangsu",
"Shanghai"
],
"tableType": "event"
},
{
"columnName": "user_level",
"comparator": "greater",
"ftv": [
"2"
],
"tableType": "user"
}
]
},
{
"type": "second",
"relation": "and",
"eventName": "obtain_diamond",
"filts": [
{
"columnName": "#os",
"comparator": "equal",
"ftv": [
"android"
],
"tableType": "event"
},
{
"$ref": "$.events[0].filts[1]"
}
]
}
],
"sliceDate": "2019-11-26",
"sliceInterval": 3,
"timeoutSeconds": 10,
"zoneOffset": 10
}
Request parameters
| $$Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| projectId | 0 | String | Yes | Description |
| eventView | - | Object | Yes | Same as the parameters of the Retention Analysis query API |
| events | List | Yes | Same as the parameters of the Retention Analysis query API | |
| sliceDate | "2019-11-26" | String | No | Date to drill down into |
| sliceGroupVal | ["Beijing"] | List | Yes | Group to drill down into |
sliceInterval | 3 | List | Yes | Index of the retention interval to drill down into
|
| timeoutSeconds | 10 | Integer | No | Request timeout. The query task is canceled when it times out |
| zoneOffset | 10 | Integer | No | Time zone |
Success response example
{
"data": {
"datalist": [
{
"#account_id": "v47739399",
"#distinct_id": "v88658799",
"user_level": 11,
"register_time": "2019-11-26 19:13:20",
"diamond_num": 1182,
"latest_login_time": "2019-11-26 20:16:19",
"channel": "Huawei AppGallery",
"#user_id": 20459799
},
{
"#account_id": "i7819568",
"#distinct_id": "i14522048",
"user_level": 4,
"register_time": "2019-11-26 23:56:17",
"diamond_num": 1006,
"latest_login_time": "2019-11-26 23:59:59",
"channel": "360 Mobile Assistant",
"#user_id": 3351248
},
{
"#account_id": "g7812426",
"#distinct_id": "g14508786",
"user_level": 14,
"register_time": "2019-11-26 17:54:13",
"diamond_num": 245,
"first_recharge_time": "2019-11-26 18:08:58",
"latest_login_time": "2019-11-26 20:16:19",
"channel": "Xiaomi GetApps",
"#user_id": 3348186
},
{
"#account_id": "a7812000",
"#distinct_id": "a14508000",
"user_level": 3,
"register_time": "2019-11-26 17:27:28",
"diamond_num": 1153,
"latest_login_time": "2019-11-26 18:45:58",
"channel": "app store",
"#user_id": 3348000
}
],
"columMeta": {
"#account_id": "Account ID",
"#distinct_id": "Distinct ID",
"user_level": "User Level",
"register_time": "Registration Time",
"diamond_num": "Current Diamonds",
"first_recharge_time": "First Top-up Time",
"latest_login_time": "Last Login Time",
"channel": "Channel"
}
},
"return_code": 0,
"return_message": "success"
}
Response parameters
| Parameter name | Example value | Parameter type | Description |
|---|---|---|---|
| return_code | 0 | Integer | Return code |
| return_message | success | String | Return message |
| data | - | Object | Returned result |
| data.datalist | - | List<Map> | User information |
| data.columMeta | - | Map | Mapping of field meanings |
Error response example
{
"return_code": -1008,
"return_message": "Parameter (token) is empty"
}
| Parameter name | Example value | Parameter type | Description |
|---|---|---|---|
| return_code | -1008 | Integer | Return code |
| return_message | Parameter (token) is empty | String | Return message |
4. Retention Analysis user list download
Endpoint URL
/open/streaming-download/retention-user-list?token=xxx
Request method
POST
Content-Type
application/json
Request query parameters
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| token | xxx | String | Yes | Query key |
Request body parameters
{
"eventView": {
"collectFirstDay": 1,
"endTime": "2022-03-07 17:09:58",
"filts": [],
"groupBy": [],
"recentDay": "1-7",
"relation": "and",
"startTime": "2022-03-01 17:09:58",
"statType": "retention",
"taIdMeasureVo": {
"columnDesc": "User ID",
"columnName": "#user_id",
"tableType": "event"
},
"timeParticleSize": "day",
"unitNum": 7
},
"events": [{
"eventName": "Login",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "first"
}, {
"eventName": "Recharge",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "second"
}],
"projectId": 319,
"isLost": false,
"sliceDate": "2022-03-01",
"sliceInterval": 0,
"selectedColumns": ["#account_id", "#distinct_id"],
"zoneOffset": 10
}
Request parameters
| $$Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| eventView | - | Object | Yes | Same as the parameters of the Retention Analysis query API |
| events | - | List | Yes | Same as the parameters of the Retention Analysis query API |
| projectId | 377 | Integer | Yes | Project ID |
| isLost | false | boolean | No | Whether the users churned |
| sliceDate | "2019-11-26" | String | No | Date of the event |
| sliceGroupVal | ["Beijing"] | List | Yes | Group to drill down into |
| sliceInterval | 0 | Integer | Yes | Index of the retention interval to drill down into
|
| selectedColumns | ["#account_id"] | List | Yes | Columns to download |
| zoneOffset | 10 | Integer | No | Time zone |
You can export the request body from the Retention Analysis page in AE, and then add the isLost, sliceDate, sliceGroupVal, sliceInterval, and selectedColumns parameters
Response
Same as the Retention Analysis user list full download in AE
Retention Analysis common enums
Retention Also Show aggregation type enum values
| Value | Description | Requires property |
|---|---|---|
| TOTAL_TIMES | Event total | No |
| TRIG_USER_NUM | Uniques | No |
| PER_CAPITA_TIMES | Times per user | No |
| SUM | Sum | Yes |
| PER_CAPITA_NUM | Per User | Yes |
| STAGE_ACC | Cumulative sum | Yes |
| STAGE_ACC_PCV | Cumulative average | Yes |
| TRUE | True totals | Yes |
| FALSE | False totals | Yes |
| IS_NOT_EMPTY | Not null totals | Yes |
| IS_EMPTY | Null totals | Yes |

