# 留存分析模型 API
调用方法请参见Open API文档中的调用方法描述。
可阅读使用手册中 留存分析 了解使用场景。
# 留存分析查询
接口 URL
/open/retention-analyze?token=xxx
请求方式
POST
Content-Type
application/json
请求 Query 参数
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
token | xxx | String | 是 | 查询密钥 |
# 请求 Body 参数
{
"eventView":{
"endTime":"2021-10-30 23:59:59",
"filts":[
{
"columnDesc":"app版本",
"columnName":"app_version",
"comparator":"equal",
"filterType":"SIMPLE",
"ftv":[
"V1.0"],
"specifiedClusterDate":"2022-01-24",
"tableType":"event",
"timeUnit":""
}],
"firstDayOfWeek":1,
"groupBy":[
{
"columnDesc":"浏览器",
"columnName":"browser",
"propertyRange":"",
"specifiedClusterDate":"2022-01-24",
"tableType":"event"
}],
"recentDay":"",
"relation":"and",
"startTime":"2021-10-01 00:00:00",
"statType":"retention",
"taIdMeasureVo":{
"columnDesc":"用户唯一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":"总次数",
"eventName":"activity_attend",
"eventNameDisplay":"",
"filts":[
],
"quota":"",
"relation":"and",
"relationUser":"and",
"type":"simultaneous_display"
}],
"projectId": 377,
"limit": 2,
"timeoutSeconds": 10,
"useCache": true
}
# 请求参数说明
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
eventView | - | Object | 是 | 指标公共属性部分 |
∟ endTime | 2021-10-30 23:59:59 | String | 否 | 结束时间(格式:yyyy-MM-dd HH:mm:ss),相对时间为空时有效 |
∟ filts | - | List | 否 | 全局筛选项 |
∟ columnDesc | app版本 | String | 否 | 字段显示名 |
∟ columnName | app_version | String | 是 | 字段名 |
∟ comparator | equal | String | 是 | 参考:模型查询API 的 筛选表达式 |
∟ filterType | SIMPLE | String | 否 | 过滤模式,SIMPLE:简单,COMPOUND:复合 |
∟ ftv | ["V1.0"] | List | 否 | 用于属性比较边界的字面常量 |
∟ specifiedClusterDate | 2022-01-24 | String | 否 | 指定对应日期的标签历史版本 |
∟ tableType | event | String | 是 | 表类型枚举值 |
∟ timeUnit | String | 否 | 属性对比值单位,仅对relativeEvent*有效:day,hour,minute | |
∟ firstDayOfWeek | 1 | Integer | 否 | 当timeParticleSize为week时,指定周首日,1:星期一,2:星期二, ..,7:星期日,最小1,最大7 |
∟ groupBy | - | List | 否 | 分组属性,可以有零个或者多个 |
∟ columnDesc | 浏览器 | String | 否 | 字段显示名 |
∟ columnName | browser | String | 是 | 字段名 |
∟ propertyRange | String | 否 | 自定义属性区间 | |
∟ specifiedClusterDate | 2022-01-24 | String | 否 | 指定对应日期的标签历史版本 |
∟ tableType | event | String | 是 | 表类型枚举值 |
∟ recentDay | String | 否 | 相对时间(此项不可与起始时间和结束时间同时为空) | |
∟ relation | and | String | 否 | 逻辑关系,and:逻辑与,or:逻辑或 |
∟ startTime | 2021-10-01 00:00:00 | String | 否 | 起始时间(格式:yyyy-MM-dd HH:mm:ss),相对时间为空时有效 |
∟ statType | retention | String | 是 | 统计类型,留存:retention,流失:lost |
∟ taIdMeasureVo | - | Object | 否 | 分析主体配置 |
∟ columnDesc | 用户唯一ID | String | 否 | 字段显示名 |
∟ columnName | #user_id | String | 是 | 字段名 |
∟ tableType | event | String | 是 | 表类型枚举值 |
∟ timeParticleSize | week | String | 是 | 分析的时间单位 day:按天 week:按周 month:按月 |
∟ unitNum | 1 | Integer | 是 | 留存期限 |
events | - | List | 是 | 事件指标列表 |
∟ eventName | login | String | 是 | 指标事件名称,可以使用 anyEvent 表示任意事件 |
∟ eventNameDisplay | String | 否 | 自定义指标显示名 | |
∟ analysis | TRIG_USER_NUM | String | 否 | 分析角度,聚合操作,具体见 留存同时展示聚合类型枚举值 |
∟ analysisDesc | 总次数 | String | 否 | 分析角度描述信息 |
∟ quota | String | 否 | 指标属性(配合analysis,意思是哪个属性的哪个分析角度) | |
∟ filts | - | List | 否 | 条件列表列表 |
∟ columnDesc | app_version | String | 否 | 字段显示名 |
∟ columnName | app_version | String | 是 | 字段名称 |
∟ comparator | equal | String | 是 | 参考:模型查询API的 筛选表达式 |
∟ filterType | SIMPLE | String | 否 | 过滤模式,SIMPLE:简单,COMPOUND:复合 |
∟ ftv | ["V1.0"] | List | 否 | 用于属性比较边界的字面常量 |
∟ specifiedClusterDate | 2022-01-26 | String | 否 | 指定对应日期的标签历史版本 |
∟ tableType | event | String | 是 | 表类型枚举值 |
∟ timeUnit | String | 否 | 过滤时间单位 | |
∟ relation | and | String | 否 | 逻辑关系,and:逻辑与,or:逻辑或 |
∟ relationUser | and | String | 否 | 用户筛选逻辑关系,and:逻辑与,or:逻辑或 |
∟ type | first | String | 是 | 留存事件类型, first:初始事件 second:回访事件 simultaneous_display:同时展示 init_date_stat:初始日期指标 |
projectId | 377 | Integer | 是 | 项目ID |
limit | 2 | Integer | 否 | 每分析对象的分组数上限,可选参数,默认为1000,最大为10000 |
timeoutSeconds | 10 | Integer | 否 | 请求超时参数,超时则取消查询任务 |
useCache | true | Boolean | 否 | 使用缓存,可选参数,默认为true |
# 成功响应示例
{
"data": {
"result_generate_time": "2022-01-01 00:00:00",
"state_avg": {
"0": [
{
"groupCols": [
"总体"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"0.998"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"0.9981"
]
}
],
"1": [
{
"groupCols": [
"总体"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"1"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"1"
]
}
],
"2": [
{
"groupCols": [
"总体"
],
"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": [
"总体"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"7388",
"7374"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"3647",
"3642"
]
}
],
"2021-10-04": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"7861",
"7844"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"3939",
"3930"
]
}
],
"2021-10-11": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"8013",
"7994"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"4062",
"4054"
]
}
],
"2021-10-18": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"8553",
"8543"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"4225",
"4218"
]
}
],
"2021-10-25": [
{
"groupCols": [
"总体"
],
"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": [
"总体"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"7388",
"7388"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"3647",
"3647"
]
}
],
"2021-10-04": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"7861",
"7861"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"3939",
"3939"
]
}
],
"2021-10-11": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"8013",
"8013"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"4062",
"4062"
]
}
],
"2021-10-18": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"8553",
"8553"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"4225",
"4225"
]
}
],
"2021-10-25": [
{
"groupCols": [
"总体"
],
"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": [
"总体"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"0",
"125324"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"0",
"62105"
]
}
],
"2021-10-04": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"0",
"132130"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"0",
"65971"
]
}
],
"2021-10-11": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"0",
"134691"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"0",
"68566"
]
}
],
"2021-10-18": [
{
"groupCols": [
"总体"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"0",
"144030"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"0",
"71345"
]
}
],
"2021-10-25": [
{
"groupCols": [
"总体"
],
"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"
}
# 响应参数说明
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
return_code | 0 | Integer | 返回码 |
return_message | success | String | 返回信息 |
data | - | Object | 返回结果 |
∟ result_generate_time | 2022-01-01 00:00:00 | String | 计算结果生成时间 |
∟ state_avg | - | Object | 结果map,key为type,value为留存分组 |
∟ {type} | - | List | type取值,0:留存,1:流失,2:同时展示指标 |
∟ groupCols | ["总体"] | List | 分组列 |
∟ initNum | 0 | Integer | 初始值 |
∟ isTotal | 1 | Integer | 是否是汇总,1:是,0:否 |
∟ lastValidDateVerticalIndexs | ["-", "4"] | List | 最后完整数据日期索引 |
∟ values | ["-", "0.998"] | List | 值列表,"-"或数字 |
∟ x | ["2021-09-27"] | List | 日期列表 |
∟ y | - | Object | y轴数据 |
∟ {type} | - | Object | type取值,0:留存,1:流失,2:统计 |
∟ {date} | - | List | key为日期 |
∟ groupCols | ["总体"] | List | 分组列 |
∟ includeToday | false | Boolean | 是否包含今日 |
∟ initNum | 7388 | Integer | 初始值 |
∟ isTotal | 1 | Integer | 是否是汇总,1:是,0:否 |
∟ values | ["7388"] | List | 值列表 |
∟ z | ["login"] | List | 事件名列表 |
错误响应示例
{
"return_code": -1008,
"return_message": "参数(token)为空"
}
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
return_code | -1008 | Integer | 返回码 |
return_message | 参数(token)为空 | String | 返回信息 |
# 留存分析全量下载
接口 URL
/open/streaming-download/retention-analyze?token=xxx
请求方式
POST
Content-Type
application/json
请求 Query 参数
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
token | xxx | String | 是 | 查询密钥 |
# 请求 Body 参数
{
"eventView": {
"collectFirstDay": 1,
"endTime": "2022-03-08 16:55:10",
"filts": [],
"groupBy": [{
"columnDesc": "渠道",
"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": "用户唯一ID",
"columnName": "#user_id",
"tableType": "event"
},
"timeParticleSize": "day",
"unitNum": 7
},
"events": [{
"eventName": "Recharge",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "first"
}],
"projectId": 390
}
# 请求参数说明
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
eventView | - | Object | 是 | 参数内容与留存分析查询接口一致 |
events | - | List | 是 | 参数内容与留存分析查询接口一致 |
projectId | 377 | Integer | 是 | 项目ID |
# 响应
同 TE 系统留存分析全量下载
# 留存分析用户列表
接口 URL
/open/retention-user-list?token=xxx
请求方式
POST
Content-Type
application/json
请求 Query 参数
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
token | xxx | String | 是 | 查询密钥 |
# 请求 Body 参数
{
"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": [
"江苏省",
"上海市"
],
"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
}
# 请求参数说明
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
projectId | 0 | String | 是 | 参数描述 |
eventView | - | Object | 是 | 参数内容与留存分析查询接口一致 |
events | List | 是 | 参数内容与留存分析查询接口一致 | |
sliceDate | "2019-11-26" | String | 否 | 哪个日期进行下钻 |
sliceGroupVal | ["北京市"] | List | 是 | 哪个分组进行下钻 |
sliceInterval | 3 | List | 是 | 哪个流程间隔进行下标 0:初始事件用户数 1:当日 2:1日后 3:2日后 |
timeoutSeconds | 10 | Integer | 否 | 请求超时参数,超时则取消查询任务 |
# 成功响应示例
{
"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": "华为应用市场",
"#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手机助手",
"#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": "小米应用商店",
"#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": "账户ID",
"#distinct_id": "访客ID",
"user_level": "用户等级",
"register_time": "注册时间",
"diamond_num": "当前拥有钻石数",
"first_recharge_time": "首次充值时间",
"latest_login_time": "最后登录时间",
"channel": "渠道"
}
},
"return_code": 0,
"return_message": "success"
}
# 响应参数说明
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
return_code | 0 | Integer | 返回码 |
return_message | success | String | 返回信息 |
data | - | Object | 返回结果 |
data.datalist | - | List | 用户信息 |
data.columMeta | - | Map | 字段含义映射 |
错误响应示例
{
"return_code": -1008,
"return_message": "参数(token)为空"
}
参数名 | 示例值 | 参数类型 | 参数描述 |
---|---|---|---|
return_code | -1008 | Integer | 返回码 |
return_message | 参数(token)为空 | String | 返回信息 |
# 留存分析用户列表下载
接口 URL
/open/streaming-download/retention-user-list?token=xxx
请求方式
POST
Content-Type
application/json
请求 Query 参数
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
token | xxx | String | 是 | 查询密钥 |
# 请求 Body 参数
{
"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"]
}
# 请求参数说明
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
eventView | - | Object | 是 | 参数内容与留存分析查询接口一致 |
events | - | List | 是 | 参数内容与留存分析查询接口一致 |
projectId | 377 | Integer | 是 | 项目ID |
isLost | false | boolean | 否 | 是否流失 |
sliceDate | "2019-11-26" | String | 否 | 事件所在日期 |
sliceGroupVal | ["北京市"] | List | 是 | 哪个分组进行下钻 |
sliceInterval | 0 | Integer | 是 | 哪个留存间隔进行下标 0:初始事件用户数 1:当前{日期单位} 2:1{日期单位}后 3:2{日期单位}后 |
selectedColumns | ["#account_id"] | List | 是 | 所需下载的列 |
TIP
请求参数主体可以从 TE 系统留存分析页面导出,添加上 isLost、sliceDate、sliceGroupVal、sliceInterval、selectedColumns 几个参数
# 响应
同 TE 系统留存分析用户列表全量下载
# 留存分析通用枚举
# 留存同时展示聚合类型枚举值
值 | 描述 | 是否需要属性 |
---|---|---|
TOTAL_TIMES | 总次数 | 否 |
TRIG_USER_NUM | 触发用户数 | 否 |
PER_CAPITA_TIMES | 人均次数 | 否 |
SUM | 数值总和 | 是 |
PER_CAPITA_NUM | 人均值 | 是 |
STAGE_ACC | 阶段累计总和 | 是 |
STAGE_ACC_PCV | 阶段累计人均值 | 是 |
TRUE | 为真数 | 是 |
FALSE | 为假数 | 是 |
IS_NOT_EMPTY | 不为空数 | 是 |
IS_EMPTY | 为空数 | 是 |
← 事件分析模型 API 漏斗分析模型 API →