目录
此内容是否有帮助?

# 事件分析模型 API

调用方法请参见Open API文档中的调用方法描述。

可阅读使用手册中 事件分析 了解使用场景。

# 事件分析查询

接口URL

/open/event-analyze?token=xxx

请求方式

POST

Content-Type

application/json

请求Query参数

参数名
示例值
参数类型
是否必填
参数描述
token
xxx
String

token

# 请求Body参数

{
    "eventView": {
        "comparedByTime": true,
        "comparedStartTime": "2021-12-14 00:00:00",
        "comparedEndTime": "2021-12-20 23:59:59",
        "comparedRecentDay": "8-14",
        "startTime": "2021-12-21 00:00:00",
        "endTime": "2021-12-27 23:59:59",
        "recentDay": "1-7",
        "relation": "and",
        "timeParticleSize": "day",
        "eventSplit": {
            "event": {
                "eventDesc": "登录",
                "eventName": "login"
            },
            "groupByProp": {
                "columnDesc": "浏览器",
                "columnName": "browser",
                "propertyRange": "",
                "tableType": "event"
            }
        },
        "groupBy": [{
            "columnDesc": "品牌",
            "columnName": "brand",
            "propertyRange": "",
            "specifiedClusterDate": "2021-12-28",
            "tableType": "event"
        }],
        "filts": [{
            "columnDesc": "品牌",
            "columnName": "brand",
            "comparator": "equal",
            "filterType": "SIMPLE",
            "ftv": ["苹果", "小米"],
            "specifiedClusterDate": "2021-12-28",
            "tableType": "event",
            "timeUnit": ""
        }],
        "queryFeature": {
            "approximateOn": true,
            "globalQueryOn": false
        }
    },
    "events": [{
        "analysis": "TOTAL_TIMES",
        "analysisParams": "",
        "eventName": "login",
        "eventNameDisplay": "登录的总次数",
        "eventSplitIndexes": [0],
        "eventUuid": "7FonAy-G",
        "filts": [],
        "quota": "",
        "relation": "and",
        "type": "normal"
    }, {
        "analysis": "TRIG_USER_NUM",
        "analysisParams": "",
        "eventName": "activity_attend",
        "eventNameDisplay": "参加活动的触发用户数",
        "eventUuid": "K9A5NDAz",
        "filts": [{
            "columnDesc": "app版本",
            "columnName": "app_version",
            "comparator": "notNull",
            "filterType": "SIMPLE",
            "ftv": [],
            "specifiedClusterDate": "2021-12-28",
            "tableType": "event",
            "timeUnit": ""
        }],
        "quota": "",
        "quotaEntities": [{
            "index": 0,
            "taIdMeasure": {
                "columnDesc": "用户唯一ID",
                "columnName": "#user_id",
                "tableType": "event"
            }
        }],
        "relation": "and",
        "type": "normal"
    }, {
        "customEvent": "logout.PER_CAPITA_TIMES",
        "customFilters": [],
        "eventName": "自定义指标",
        "eventNameDisplay": "",
        "eventSplitIndexes": [],
        "eventUuid": "gxqT19xz",
        "filts": [],
        "format": "float",
        "quota": "",
        "quotaEntities": [{
            "index": 0,
            "taIdMeasure": {
                "columnDesc": "邮箱",
                "columnName": "email",
                "tableType": "user"
            }
        }],
        "quotaTimeRanges": [{
            "index": 0,
            "params": ["1"],
            "type": "THIS_WEEK"
        }],
        "relation": "and",
        "type": "customized"
    }],
    "projectId": 377,
    "useSameResultKey": false,
    "useCache": true,
    "limit": 1000,
    "timeoutSeconds": 10
}

提示

入参由多部分组成其中:基础参数必选;时间对比参数、事件拆分参数、分组项参数、全局筛选项参数、查询配置项参数可选;普通分析指标和自定义分析指标二选一。

# 请求参数说明

参数名
示例值
参数类型
是否必填
参数描述
eventView
-
Object

分组属性
comparedByTime true
Boolean

是否对比时间,TRUE:是,FALSE:否
comparedStartTime 2021-12-14 00:00:00
String

对比时间开始时间(格式:yyyy-MM-dd HH:mm:ss),对比时间相对时间为空时有效
comparedEndTime 2021-12-20 23:59:59
String

对比时间结束事件(格式:yyyy-MM-dd HH:mm:ss),对比时间相对时间为空时有效
comparedRecentDay 8-14
String

对比时间相对时间(comparedByTime为TRUE时,此项不可与对比时间起始时间和对比时间结束时间同时为空)
startTime 2021-12-21 00:00:00
String

起始时间(格式:yyyy-MM-dd HH:mm:ss),相对时间为空时有效
endTime 2021-12-27 23:59:59
String

结束时间(格式:yyyy-MM-dd HH:mm:ss),相对时间为空时有效
recentDay 1-7
String

相对时间(此项不可与起始时间和结束时间同时为空)
relation and
String

逻辑关系,and:逻辑与,or:逻辑或
timeParticleSize day
String

分析的时间单位
minute:按1分钟
minute5:按5分钟(v3.5开始支持)
minute10:按10分钟(v3.5开始支持)
hour:按小时
day:按天
week:按周
month:按月
total:总计
eventSplit -
Object

事件拆分信息
event -
Object

事件拆分事件信息
eventDesc 登录
String

事件拆分指标显示名
eventName login
String

事件拆分指标事件名
groupByProp -
Object

事件拆分指标分组信息
columnDesc 浏览器
String

事件拆分分组字段显示名
columnName browser
String

事件拆分分组字段字段名
propertyRange String

事件拆分分组属性区间
tableType event
String

事件拆分表类型,event:事件表,user:用户表
groupBy -
List

分组属性,可以有零个或者多个
columnName brand
String

字段名
columnDesc 品牌
String

字段显示名
propertyRange String

自定义属性区间
propertyRangeType String

属性区间类型,对数值型属性进行分组时,可以为自定义分桶条件
def:默认区间,由系统自动划分
discrete:每个值为一个独立的分组
user_defined:用户自定义。自定义内容设置在 propertyRange 中
specifiedClusterDate 2021-12-28
String

集群指定日期
tableType event
String

表类型,event:事件表,user:用户表
filts -
List

全局筛选项
columnDesc 品牌
String

字段显示名
columnName brand
String

字段名
comparator equal
String

参考: 模型查询API的筛选表达式
filterType SIMPLE
String

过滤模式,SIMPLE:简单,COMPOUND:复合
ftv ["苹果", "小米"]
List

属性对比值
specifiedClusterDate 2021-12-28
String

集群指定日期
tableType event
String

表类型,event:事件表,user:用户表
timeUnit String

属性对比值单位,仅对relativeEvent*有效:day,hour,minute
queryFeature -
Object

查询配置
approximateOn true
Boolean

是否开启近似计算
globalQueryOn false
Boolean

是否开启多集群计算
events
-
List

事件指标列表
analysis TRIG_USER_NUM
String

分析角度,聚合操作,具体见下表
analysisParams String

分析角度参数(analysis为PERCENTILE时不能为空,取值范围:1-100,代表几分位)
eventName activity_attend
String

事件名称,特别的,可以使用 anyEvent 表示任意事件
eventNameDisplay 参加活动的触发用户数
String

事件显示名
eventUuid K9A5NDAz
String

事件UUID,用来标识事件唯一
filts -
List

条件列表列表
columnDesc app版本
String

字段显示名
columnName app_version
String

字段名称
comparator notNull
String

参考:模型查询API的筛选表达式
filterType SIMPLE
String

过滤模式,SIMPLE:简单,COMPOUND:复合
ftv []
List

属性对比值
specifiedClusterDate 2021-12-28
String

tableType event
String

表类型,event:事件表,user:用户表
timeUnit String

过滤时间单位
quota String

指标属性(配合analysis,意思是哪个属性的哪个分析角度)
quotaDesc String

指标属性显示名
quotaEntities -
List
分析事件指标对应的主体列表
index 0
Integer

分析事件指标对应的主体下标
taIdMeasure -
Object
查询ID体系配置
columnDesc 用户唯一ID
String

字段显示名
columnName #user_id
String

字段名称
tableType event
String

表类型,event:事件表,user:用户表
relation and
String

逻辑关系,and:逻辑与,or:逻辑或
type normal
String

normal:普通分析
customized:自定义公式
customEvent logout.PER_CAPITA_TIMES
String

公式表达式,由分析项或数值常量的加减乘除构成。分析项有两种形式: eventName.columnName.analysis 或 eventName.analysis。
customFilters []
List

公式表达式过滤项列表
eventName 自定义指标
String

自定义指标显示名
eventNameDisplay String

eventSplitIndexes []
List

参与事件拆分的项
eventUuid gxqT19xz
String

自定义指标UUID,用来标识指标唯一
filts []
List

筛选项列表
format float
String

展示数据的选项
float:两位小数,float3:三位小数,float4:四位小数,percent:百分比
quota String

指标属性(配合analysis,意思是哪个属性的哪个分析角度)
quotaDesc String

指标属性显示名
quotaEntities -
List

分析事件指标对应的主体列表
index 0
Integer

分析事件指标对应的主体下标
taIdMeasure -
Object

查询ID体系配置
columnDesc 邮箱
String

字段显示名
columnName email
String

字段名称
tableType user
String

表类型,event:事件表,user:用户表
quotaTimeRanges []
List

指标时间段信息列表
index 0
Integer

时间段下标
params ["1"]
List

时间段参数
type THIS_WEEK
String

时间段类型
LAST_DAYS:过去几天,RECENT_DAYS:最近几天,THIS_WEEK:当周,THIS_MONTH:当月
relation and
String

逻辑关系,and:逻辑与,or:逻辑或
type customized
String

normal:普通分析
customized:自定义公式
projectId
377
Integer

项目Id
useSameResultKey
false
Boolean

当事件名相同时,是否使用相同事件名
true:使用相同事件名
false:事件名相同时,添加前缀编号
useCache
true
Boolean

使用缓存,可选参数,默认为true
limit
1000
Integer

每分析对象的分组数上限,可选参数,默认为1000,最大为10000
timeoutSeconds
10
Integer

请求超时参数,超时则取消查询任务

聚合方法 analysis 取值:


描述
是否需要属性
TOTAL_TIMES
总次数

TRIG_USER_NUM
触发用户数

PER_CAPITA_TIMES
人均次数

SUM
数值总和

AVG
数值平均值

PER_CAPITA_NUM
人均值

MAX
数值最大值

MIN
数值最小值

DISTINCT
去重数

TRUE
为真数

FALSE
为假数

IS_NOT_EMPTY
不为空数

IS_EMPTY
为空数

ARRAY_DISTINCT
列表整体去重数

ARRAY_SET_DISTINCT
元素集合去重数

ARRAY_ITEM_DISTINCT
列表元素去重数

MEDIAN
中位数

PERCENTILE
分位数

# 成功响应示例

相同条件在TA事件分析操作后趋势图和按日期表格结果如下

{
    "data": {
        "result_generate_time": "2021-12-30 11:15:41", 
        "union_groups": [
            [
                "Safari", 
                "苹果"
            ], 
            [
                "Firefox", 
                "小米"
            ], 
            [
                "微信内置浏览器", 
                "苹果"
            ], 
            [
                "总体", 
                "苹果"
            ], 
            [
                "总体", 
                "小米"
            ]
        ], 
        "x": [
            "2021-12-23", 
            "2021-12-24", 
            "2021-12-25", 
            "2021-12-26", 
            "2021-12-27", 
            "2021-12-28", 
            "2021-12-29"
        ], 
        "x_compared": [
            "2021-12-16", 
            "2021-12-17", 
            "2021-12-18", 
            "2021-12-19", 
            "2021-12-20", 
            "2021-12-21", 
            "2021-12-22"
        ], 
        "y": [
            {
                "login.TOTAL_TIMES": [
                    {
                        "group_cols": [
                            "Safari", 
                            "苹果"
                        ], 
                        "group_num": 3, 
                        "values": [
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "447", 
                            "980", 
                            "1584", 
                            "321", 
                            "285", 
                            "74", 
                            "0"
                        ]
                    }, 
                    {
                        "group_cols": [
                            "Firefox", 
                            "小米"
                        ], 
                        "group_num": 3, 
                        "values": [
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "291", 
                            "818", 
                            "1128", 
                            "272", 
                            "219", 
                            "58", 
                            "0"
                        ]
                    }, 
                    {
                        "group_cols": [
                            "微信内置浏览器", 
                            "苹果"
                        ], 
                        "group_num": 3, 
                        "values": [
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "231", 
                            "500", 
                            "764", 
                            "214", 
                            "155", 
                            "35", 
                            "0"
                        ]
                    }
                ]
            }, 
            {
                "activity_attend.TRIG_USER_NUM": [
                    {
                        "group_cols": [
                            "总体", 
                            "苹果"
                        ], 
                        "group_num": 2, 
                        "values": [
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "640", 
                            "811", 
                            "1251", 
                            "1253", 
                            "720", 
                            "113", 
                            "0"
                        ]
                    }, 
                    {
                        "group_cols": [
                            "总体", 
                            "小米"
                        ], 
                        "group_num": 2, 
                        "values": [
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "277", 
                            "439", 
                            "600", 
                            "666", 
                            "364", 
                            "59", 
                            "0"
                        ]
                    }
                ]
            }, 
            {
                "自定义指标": [
                    {
                        "group_cols": [
                            "总体", 
                            "苹果"
                        ], 
                        "group_num": 2, 
                        "values": [
                            "1", 
                            "1", 
                            "1", 
                            "1", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "1.01", 
                            "1.01", 
                            "1.01", 
                            "1.01", 
                            "1", 
                            "1", 
                            "1"
                        ]
                    }, 
                    {
                        "group_cols": [
                            "总体", 
                            "小米"
                        ], 
                        "group_num": 2, 
                        "values": [
                            "1", 
                            "1", 
                            "1", 
                            "1", 
                            "0", 
                            "0", 
                            "0"
                        ], 
                        "values_compared": [
                            "1.01", 
                            "1.01", 
                            "1.01", 
                            "1.01", 
                            "1", 
                            "1", 
                            "1"
                        ]
                    }
                ]
            }
        ]
    }, 
    "return_code": 0, 
    "return_message": "success"
}

# 响应参数说明

参数名
示例值
参数类型
参数描述
data
-
Object
返回结果
result_generate_time 2021-12-29 12:00:00
String
查询结果生成时间
union_groups ["苹果"]
List
分组
x ["2021-12-23"]
List
X轴时间
x_compared ["2021-12-16"]
List
X轴对比时间
y -
List
Y轴数据列表
{指标名称} -
List
Y轴指标信息列表
group_cols ["苹果"]
List
Y轴指标分组
group_num 3
Integer
Y轴指标分组数量
values ["0"]
List
Y轴指标数值
values_compared ["447"]
List
Y轴时间对比指标数值
return_code
0
Integer
返回码
return_message
success
String
返回信息

错误响应示例

{
    "return_code": -1008,
    "return_message": "参数(token)为空"
}
参数名
示例值
参数类型
参数描述
return_code
-1008
Integer
返回码
return_message
参数(token)为空
String
返回信息

curl 示例

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"projectId": 377,"useSameResultKey": false,"useCache": true,"limit": 1000,"eventView": {"comparedByTime": true,"comparedStartTime": "2021-12-14 00:00:00","comparedEndTime": "2021-12-20 23:59:59","comparedRecentDay": "8-14","startTime": "2021-12-21 00:00:00","endTime": "2021-12-27 23:59:59","recentDay": "1-7","relation": "and","timeParticleSize": "day","eventSplit": {"event": {"eventDesc": "登录","eventName": "login"},"groupByProp": {"columnDesc": "浏览器","columnName": "browser","propertyRange": "","tableType": "event"}},"groupBy": [{"columnDesc": "品牌","columnName": "brand","propertyRange": "","specifiedClusterDate": "2021-12-28","tableType": "event"}],"filts": [{"columnDesc": "品牌","columnName": "brand","comparator": "equal","filterType": "SIMPLE","ftv": ["苹果", "小米"],"specifiedClusterDate": "2021-12-28","tableType": "event","timeUnit": ""}],"queryFeature": {"approximateOn": true,"globalQueryOn": false}},"events": [{"analysis": "TOTAL_TIMES","analysisParams": "","eventName": "login","eventNameDisplay": "登录的总次数","eventSplitIndexes": [0],"eventUuid": "7FonAy-G","filts": [],"quota": "","relation": "and","type": "normal"}, {"analysis": "TRIG_USER_NUM","analysisParams": "","eventName": "activity_attend","eventNameDisplay": "参加活动的触发用户数","eventUuid": "K9A5NDAz","filts": [{"columnDesc": "app版本","columnName": "app_version","comparator": "notNull","filterType": "SIMPLE","ftv": [],"specifiedClusterDate": "2021-12-28","tableType": "event","timeUnit": ""}],"quota": "","quotaEntities": [{"index": 0,"taIdMeasure": {"columnDesc": "用户唯一ID","columnName": "#user_id","tableType": "event"}}],"relation": "and","type": "normal"}, {"customEvent": "logout.PER_CAPITA_TIMES","customFilters": [],"eventName": "自定义指标","eventNameDisplay": "","eventSplitIndexes": [],"eventUuid": "gxqT19xz","filts": [],"format": "float","quota": "","quotaEntities": [{"index": 0,"taIdMeasure": {"columnDesc": "邮箱","columnName": "email","tableType": "user"}}],"quotaTimeRanges": [{"index": 0,"params": ["1"],"type": "THIS_WEEK"}],"relation": "and","type": "customized"}]}' 'http://ta2:8992/open/event-analyze?token=bTOzKiTIozG4e19FgXphcA8dDV3DIY8RwdHTO7aSnBsRqSNaIk19BnBMecJDWibD'

# 事件分析用户列表

接口URL

/open/event-user-list?token=xxx

请求方式

POST

Content-Type

application/json

请求Query参数

参数名
示例值
参数类型
是否必填
参数描述
token
xxx
String

token

# 请求Body参数

{
  "projectId": 0,
  "eventView": {
    "startTime": "2019-11-24 00:00:00",
    "endTime": "2019-11-26 00:00:00",
    "recentDay": "1-3",
    "timeParticleSize": "day",
    "groupBy": [
      {
        "columnName": "#city",
        "tableType": "event"
      }
    ]
  },
  "events": [
    {
      "analysis": "TRIG_USER_NUM",
      "eventName": "consume_item",
      "quota": "#vp@dailyTask",
      "relation": "and",
      "type": "normal",
      "filts": [
      {
          "columnName": "user_level",
          "comparator": "equal",
          "ftv": [
            "5"
          ],
          "tableType": "user"
        }
      ],
    }
  ],
  "sliceDate": "2019-11-26",
  "sliceGroupVal": [
    "北京市"
  ],
  "timeoutSeconds": 10
}

# 请求参数说明

参数名
示例值
参数类型
是否必填
参数描述
projectId
0
String

参数描述
eventView
-
Object

分组属性表
startTime 2019-11-24 00:00:00
String

起始时间(格式:yyyy-MM-dd HH:mm:ss),相对时间为空时有效
endTime 2019-11-26 00:00:00
String

结束时间(格式:yyyy-MM-dd HH:mm:ss),相对时间为空时有效
recentDay 1-3
String

相对时间(此项不可与起始时间和结束时间同时为空)
timeParticleSize day
String

分析的时间单位
minute:按1分钟
minute5:按5分钟(v3.5开始支持)
minute10:按10分钟(v3.5开始支持)
hour:按小时
day:按天
week:按周
month:按月
total:总计
groupBy -
List

分组属性,可以有零个或者多个
columnName #city
String

字段名
tableType event
String

表类型,event:事件表,user:用户表
events
List

事件指标列表
analysis TRIG_USER_NUM
String

分析类型,聚合操作,具体见下表
eventName consume_item
String

事件名称,特别的,可以使用 anyEvent 表示任意事件
quota #vp@dailyTask
String

指标属性(配合analysis,意思是哪个属性的哪个分析角度)
relation and
String

逻辑关系,and:逻辑与,or:逻辑或
type normal
String

normal:普通分析
customized:自定义公式
filts -
List

筛选项列表
columnName user_level
String

字段名称
comparator equal
String

参考:模型查询API的筛选表达式
ftv ["5"]
List

属性对比值
tableType user
String

表类型,event:事件表,user:用户表
sliceDate
"2019-11-26"
String

事件所在日期
sliceGroupVal
["北京市"]
List

事件所在分组
timeoutSeconds
10
Integer

请求超时参数,超时则取消查询任务

# 成功响应示例

{
  "data": {
    "datalist": [
      {
        "#account_id": "e78107482",
        "#distinct_id": "e145056682",
        "user_level": 5,
        "register_time": "2019-11-26 14:36:13",
        "diamond_num": 1006,
        "latest_login_time": "2019-11-26 15:45:16",
        "channel": "app store",
        "#user_id": 33474682
      },
      {
        "#account_id": "d7819213",
        "#distinct_id": "d14521393",
        "user_level": 5,
        "register_time": "2019-11-26 23:25:14",
        "diamond_num": 858,
        "first_recharge_time": "2019-11-26 23:29:56",
        "latest_login_time": "2019-11-26 23:32:48",
        "channel": "app store",
        "#user_id": 3351093
      }
    ],
    "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
返回结果
datalist -
List
用户信息
columMeta -
Map
字段含义映射

错误响应示例

{
    "return_code": -1008,
    "return_message": "参数(token)为空"
}
参数名
示例值
参数类型
参数描述
return_code
-1008
Integer
返回码
return_message
参数(token)为空
String
返回信息