This document is intended for users who are experienced in related functions. The content described in this document is an advanced application function of the wizard analysis and involves more technical details. If you have any doubts about the content of the document, please consult the student on duty for one-on-one assistance.


The query API is mainly used to obtain various data analysis reports.

1. Calling method

Please see API Document description of the calling method

2.  Universal parameter

2.1. Attribute expression

Almost all api use attribute expressions, such as filtering, grouping, or aggregating by an attribute. Properties include event properties and user properties. Event properties are used event.event name.attribute name ways, Example representation Page title The expression for this property is as follows:

Example presentation
event.$pageview.$title

User attributes are similar, such as presentation User gender:

Example presentation
user.Gender

2.2. Filter expression

Filter expressions are also suitable for most apis, and are used to represent filtering operations on certain events or users, using JSON representations in the following format:

Example presentation
{
// 表示 conditions 里的各个条件的关系是 "或" 还是 "且" "relation": "and",
// 具体的条件列表,可以有多个 "conditions": [ {
// 条件的左值,是一个属性表达式 "field": "event.BuyGold.$os",
// 条件的操作符,这里表示等于 "function": "equal",
// 条件的参数,根据不同的操作符可以有一个或者多个 "params": [ "iOS" ] }, { "field": "user.Gender", "function": "equal", "params": [ "男" ] } ] }


Currently, the following operators are supported:

  • equal / notEqual

        The value is equal to or not equal to a string or numeric value. If there are more than one Params, it is equivalent to In or Not In. For example, if you want to screen out users from Beijing or Shanghai:

Example presentation
{ "field": "user.$city",  "function": "equal",  "params": [ "北京",  "上海" ] }


  •  isTrue / isFalse

        Only valid for Boolean types.

  •  isSet / notSet

        Whether an attribute has a value, valid for string and numeric types.

  •  include

        An operation on a collection that contains an element, such as filtering out all users who like Apple:

Example presentation
{ "field": "user.FavoriteFruits",  "function": "include",  "params": [ "Apple" ] }


  •  less / greater / between:Represents less than/greater than/less than and greater than, where between is the interval before and after closing, valid only for numeric types. For example, screening all events where the price of buying gold is between 230 and 232:
Example presentation
{ "field": "event.BuyGold.GoldPrice",  "function": "between",  "params": [ 230,  232 ] }


  • contain / notContain

        Contains or does not contain: indicates a partial match of the string. This parameter is valid only for the string type.

  • absoluteBetween / relativeBefore / relativeWithin

        Operators for date types that represent an absolute date range/before/within N days, respectively. For example, if you want to filter all users registered within 3 days:

Example presentation
{ "field": "user.$signup_time",  "function": "relativeWithin",  "params": [ 3 ] }


        Or filter all registered users from 2015-1-1 to 2015-1-10:

Example presentation
{ "field": "user.$signup_time",  "function": "absoluteBetween",  "params": [ "2015-01-01",  "2015-01-10" ] }


2.3. Parameter description

Parameter nameParameter meaningValue rangeRequired field
aggregatorAggregate operator

general:Event trigger times

unique:Trigger number of users 

average/uniqAvg:Per capita frequency/per capita value 

SUM:Sum of values

MAX: Maximum value

MIN: Minimum value

AVG: Average value

Y
event_nameEvent NameEvent name in metadata, the event must be visibleY
filterFilter condition for querying metrics


N
fieldAggregated field nameIf the aggregator is sum/max/min/avg, you need to add the field, which is the name of the aggregated field. It should be at the same level as the aggregator. For example: "field" : "event.payOrder.discountAmount"N
by_fieldsGrouping by a specific attributeAttribute name of the eventN
bucket_paramsBucket ParametersWhen grouping numerical attributes, you can customize the bucket parameters. The attributes included in the bucket parameters must be fully included in the grouping attributes "by_fields".
unitTime granularity of metric queryhour, day, week, month (Currently, the API does not support querying at the minute granularity level, and the minimum granularity is hour)Y
from_date/to_dateStart date/End date of the query

All analysis interfaces support filtering with "day" precision. Only in funnel analysis, "from_date" and "to_date" support filtering with "second" or "day" precision.

Example:

// Using second precision

"from_date": "2021-07-17 22:00:00", "to_date": "2021-07-18 22:00:00" - The system will match all data with a time range of 2021-07-17 22:00:00.000 to 2021-07-18 22:00:00.999

// Using day precision

"from_date": "2021-07-17", "to_date": "2021-07-18" - The system will match all data with a time range of 2021-07-17 00:00:00.000 to 2021-07-18 23:59:59.999

Y
slice_by_valuesCorresponding to "by_fields", when viewing the number of triggered users for a specific attribute value in a group, use this parameter to specify.Value corresponding to the attribute in "by_fields"N
rollup_dateSummary date

true/false。

true: Corresponding to "from_date":"2018-05-29","to_date":"2018-05-30" time range, it is the total value of the selected time range on the page.
false: Corresponding to "slice_date": "2018-05-29 00:00:00" value at a specific time point, which is the value displayed in a specific grid on the page

Default is false
slice_dateSlicing time, which corresponds to a specific slicing time when viewing by minute/hour/day/week/month on the page.

The value of slice_date is determined by the time granularity specified in the unit parameter. It can be minute/hour/day/week/month. The value of slice_date corresponds to the selected time range.

Required when rollup_date is false
detailWhether to display all user attributes

true/false。

true: Display all visible user attributes. false: Only display id, first_id, second_id.

N, default is false
profilesSpecify which user attributes to displayUser attribute nameN, If this parameter is not specified, and detail is set to true, all visible user attributes will be displayed. If detail is set to false, only id will be displayed.
num_per_pageNumber of rows displayed per page

Customize parameter value

Note: This is only used for event analysis user list

N, default is 30 rows
pageSpecify the Nth page to return (starting from 0)Note: This is only used for event analysis user listN

limit

Limit the number of returns

Maximum number of groups (a too large limit may cause server OOM). If this field is not passed, the number of groups returned will be calculated based on the following rules: 10000 / the number of time periods / the number of metrics, the number of time periods refers to how many time periods units are included in from_date and to_date, and the number of metrics refers to the number of measures in the measures array

Note: This is only used for event analysis

N, default is up to 10,000 rows
approxWhether to calculate approximately
N
approx_totalWhether the total should be calculated approximately

Use approximate calculation for the total. When "approx" is true, "approx_total" should also be set to true. When "approx" is false, if "approx_total" is true, the total will be calculated using approximate algorithm

N
use_cacheWhether to use cache
N
report_update_timeTime when the result was generated

date_update_timeLast update time of the data related to the query event

date_sufficient_update_timeLast update time of the data related to the query event that exceeds 1%

3. Behavior Analysis Report

All analysis reports are available in both JSON and CSV formats. The default format is JSON. If you need CSV format data, you can manually specify the format parameter. For example, the CSV format URL for the event analysis report is: /events/report?format=csv.

3.1. Event Analysis Report

[POST /events/report]

{
"measures":[
{
// 事件名称,特别的,可以使用 $Anything 表示任意事件
"event_name":"$AppClick",
// 聚合操作符
"aggregator":"unique",
//(可选)对于指标的筛选条件
"filter": {
"conditions": [
{
// 指标事件属性
"field": "event.$AppClick.$lib",
// 筛选条件的操作符,equal 这里表示 等于。此处支持多种,如包含等。具体参考文档开头通用参数
"function": "equal",
// 属性的具体值
"params": [
"iOS"
]
}
]
}
}
],
// 起始日期
"from_date":"2021-07-12",
// 结束日期
"to_date":"2021-07-15",
// 时间单位,可以是小时/天/周/月, hour/day/week/month
"unit":"day",
//(可选)筛选条件,全局筛选条件,如果有多指标,该处筛选条件对全部指标有效。
"filter":{
//(可选)筛选条件的关联关系,and 表示'且',or 表示'或'。
"relation":"and",
"conditions":[
{
"field":"event.$AppClick.$country",
"function":"equal",
"params":[
"中国"
]
},
{
"field":"event.$AppClick.$city",
"function":"equal",
"params":[
"北京"
]
}
]
},
//(可选)分组属性,可以有零个或者多个
"by_fields":[
"event.$AppClick.$screen_width",
"event.$AppClick.$screen_height"
],
//(可选)分桶条件,对数值型属性进行分组时,可以自定义分桶条件,如果不设置的话,是默认区间
"bucket_params":{
"event.$AppClick.$screen_width":[100,200],
"event.$AppClick.$screen_height":[1000]
},
// 是否计算合计值
"detail_and_rollup":true,
//(可选)抽样因子,64为全量,32为2分之1抽样
"sampling_factor":64,
//(可选)使用近似计算
"approx":true,
//(可选)基数计算算法hyperloglog的精度,值越大精度越高,但对应内存占用也会变高,推荐用12。
"hll_precision":12,
//(可选)使用近似计算合计,当“approx”为true时,“approx_total”也设为true,当“approx”为false时,如果“approx_total”为true,那合计会以近似计算算法得出
"approx_total":false,
//(可选)最大分组个数
"limit":1000,
//(可选)使用缓存,若缓存中找不到相应数据,则从数据库读出
"use_cache":true
}
{
// 查询所用到的分组属性
"by_fields":[
"event.$Anything.$screen_width",
"event.$Anything.$screen_height"
],
// 查询的时间范围,因为是按天查看,所以会展示每天,如果按周聚合的话,展示的是每周的周一的时间。
"series":[
"2021-07-12 00:00:00",
"2021-07-13 00:00:00",
"2021-07-14 00:00:00",
"2021-07-15 00:00:00"
],
// 查询结果的行数,对应的每行的值,按日期正叙展示每天的值。
"rows":[
{
// 查询结果,第一行的值[0],[0][1][0],对应[2021-07-15 00:00:00][2021-07-14 00:00:00][2021-07-13 00:00:00][2021-07-12 00:00:00]每天的数据
"values":[
[0],
[0],
[1],
[0]
],
// 查询结果,第一行的属性值"-INF~100","-INF~1000" 表示第一个分组属性的值、第二个分组属性的值。
"by_values":[
"-INF~100",
"-INF~1000"
]
},
{
"values":[
[1],
[0],
[0],
[0]
],
"by_values":[
"-INF~100",
"1000~INF"
]
}
],
// 行数
"num_rows": 2,
// 总行数
"total_rows": 2,
// 全量缓存更新时间
"report_update_time": "2021-07-15 16:51:08.356",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2021-07-15 16:03:32.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2021-07-15 16:03:32.000",
// 查询是否截断
"truncated": false
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/events/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
"measures": [
{
"event_name": "$AppClick",
"aggregator": "unique",
"filter": {
"conditions": [
{
"field": "event.$AppClick.$lib",
"function": "equal",
"params": [
"iOS"
]
}
]
}
}
],
"from_date": "2021-07-12",
"to_date": "2021-07-1502",
"unit": "day",
"filter": {
"relation": "and",
"conditions": [
{
"field": "event.$AppClick.$country",
"function": "equal",
"params": [
"中国"
]
},
{
"field": "event.$AppClick.$city",
"function": "equal",
"params": [
"北京"
]
}
]
},
"by_fields": [
"event.payOrder.$screen_width",
"event.payOrder.$screen_height"
],
"bucket_params": {
"event.payOrder.$screen_width": [
100,
200
],
"event.payOrder.$screen_height": [
1000
]
},
"unit":"day",
"detail_and_rollup": true,
"sampling_factor": 64,
"approx": true,
"hll_precision": 12,
"approx_total": false,
"limit": 1000,
"use_cache": true
}

'

3.2. Session Analysis Report

[POST /events/report]

{
  // session名称
  "session_name": "testssss",
  // 查询指标
  "measures": [{
    // 聚合操作符
    "aggregator": "general",
    // 是否是 session 总体相关指标.  特别的,当查询 session 总体指标时,event_name 为 $Anything
    "by_session": true,
    // 事件名
    "event_name": "$Anything"
  }, {
    // 事件属性指标
    "aggregator": "SUM",
    "by_session": false,
    "event_name": "$AppClick",
    "field": "event.$AppClick.$screen_width"
  }, {
    // 查session属性指标
    "aggregator": "SUM",
    "by_session": true,
    "event_name": "$Anything",
    // 当指标中涉及属性时(filed),属性需要符合以下规则
    // 对于 sa2.4+ 的版本 ,   session 属性的格式为 session_session名.事件名.属性名
    // 对于 sa2.3.3 及以下版本,session 属性的格式为 session.事件名.属性名
    "field": "session_testssss.$Anything.$screen_width$session",
    // (可选)  指标内筛选
    "filter": {
      "conditions": [{
        // 筛选以及分组中 session 属性格式为: session.事件名.属性名
        "field": "session.$Anything.$lib$session",
        "function": "equal",
        "params": ["iOS"]
      }]
    }
  }],
  // (可选) 分组属性.  特别的. 当指标中设计 session 总体指标时,分组不能按照事件属性分组
  "by_fields": ["session.$Anything.$element_id$session", "session.$Anything.$lib$session"],
  // (可选) 全局筛选
  "filter": {
    //(可选)筛选条件的关联关系,and 表示'且',or 表示'或'
    "relation":"and",
    "conditions": [{
      "field": "session.$Anything.$lib$session",
      "function": "equal",
      "params": ["iOS"]
    }, {
      "field": "session.$Anything.$element_id$session",
      "function": "isSet",
      "params": []
    }]
  },
  // 起始时间
  "from_date": "2021-11-30",
  // 结束时间
  "to_date": "2021-11-30",
  // 查询单位, 可以是小时/天/周/月, hour/day/week/month
  "unit": "day",
  // 是否计算合计值
  "detail_and_rollup":true,
  //(可选)抽样因子,64为全量,32为2分之1抽样
  "sampling_factor":64,
  //(可选)使用近似计算
  "approx":true,
  //(可选)基数计算算法hyperloglog的精度,值越大精度越高,但对应内存占用也会变高,推荐用12。
  "hll_precision":12,
  //(可选)使用近似计算合计,当“approx”为true时,“approx_total”也设为true,当“approx”为false时,如果“approx_total”为true,那合计会以近似计算算法得出
  "approx_total":false,
  //(可选)最大分组个数
  "limit":1000,
  //(可选)使用缓存,若缓存中找不到相应数据,则从数据库读出
  "use_cache":true
  // (可选) 跨天 session 是否需要切割, 默认为 true
  "split_by_day":true
}

{
  // 明细
  "detail_result":{
    // 查询中所用到的分组
    "by_fields":[
      "session.$Anything.$element_id$session",
      "session.$Anything.$lib$session"],
    // 查询的时间范围,因为是按天查看,所以会展示每天,如果按周聚合的话,展示的是每周的周一的时间。
    "series":[
      "2021-11-30 00:00:00"],
    // 查询结果的行数,对应的每行的值,按日期倒叙展示每天的值。
    "rows":[
      {
        "values":[
          [
            1025,
            312022.000,
            628628.000]],
        "by_values":[
          "5",
          "iOS"]
      },
      {
        "values":[
          [
            941,
            304106.000,
            542104.000]],
        "by_values":[
          "1",
          "iOS"]
      }],
    // 行数
    "num_rows":2,
    // 总行数
    "total_rows":2,
    // 是否近似计算
    "approx":false,
    // 下载是否截断
    "download_truncated":false,
    // 查询结果是否截断
    "truncated":false
  },
  // 合计
  "rollup_result":{
    "by_fields":[
      "session.$Anything.$element_id$session",
      "session.$Anything.$lib$session"],
    "series":[
      "2021-11-30 00:00:00"],
    "rows":[
      {
        "values":[
          [
            1025,
            312022.000,
            628628.000]],
        "by_values":[
          "5",
          "iOS"],
        "avg_values":[
          [
            1025.0,
            312022.0,
            628628.0]],
        "min_values":[
          [
            1025,
            312022.000,
            628628.000]],
        "max_values":[
          [
            1025,
            312022.000,
            628628.000]]
      },
      {
        "values":[
          [
            941,
            304106.000,
            542104.000]],
        "by_values":[
          "1",
          "iOS"],
        "avg_values":[
          [
            941.0,
            304106.0,
            542104.0]],
        "min_values":[
          [
            941,
            304106.000,
            542104.000]],
        "max_values":[
          [
            941,
            304106.000,
            542104.000]]
      }],
    "num_rows":2,
    "total_rows":2,
    "approx":false,
    "download_truncated":false,
    "truncated":false
  },
  // 明细的合计
  "total_detail_result":{
    "by_fields":[
      "session.$Anything.$element_id$session",
      "session.$Anything.$lib$session"],
    "series":[
      "2021-11-30 00:00:00"],
    "rows":[
      {
        "values":[
          [
            1966,
            616128.000,
            1170732.000]],
        "by_values":[
        ]
      }],
    "num_rows":1,
    "total_rows":1,
    "approx":false,
    "download_truncated":false,
    "truncated":false
  },
  // 合计的合计
  "total_rollup_result":{
    "by_fields":[
      "session.$Anything.$element_id$session",
      "session.$Anything.$lib$session"],
    "series":[
      "2021-11-30 00:00:00"],
    "rows":[
      {
        "values":[
          [
            1966,
            616128.000,
            1170732.000]],
        "by_values":[
          "$layer_total_reserved_word"]
      }],
    "num_rows":1,
    "total_rows":2,
    "approx":false,
    "download_truncated":false,
    "truncated":false
  },
  "measure_approx_maps":{
    "0":false,
    "1":false,
    "2":false
  },
  "download_truncated":false,
  "user_tag_values":{
  },
  "report_update_time":"2023-07-10 16:42:32.230",
  "data_update_time":"2021-12-30 17:07:38.000",
  "data_sufficient_update_time":"2021-12-30 17:07:38.000",
  "truncated":false,
  "sampling_factor":64
}

curl 'http://10.129.27.41:8107/api/events/report?token=$eb039b3f8592998e3a05515b25afd9e&project=QETesting' \
-H 'Content-Type: application/json' \
--data-binary '
{
  "session_name": "testssss",
  "measures": [{
    "aggregator": "general",
    "by_session": true,
    "event_name": "$Anything"
  }, {
    "aggregator": "SUM",
    "by_session": false,
    "event_name": "$AppClick",
    "field": "event.$AppClick.$screen_width"
  }, {
    "aggregator": "SUM",
    "by_session": true,
    "event_name": "$Anything",
    "field": "session_testssss.$Anything.$screen_width$session",
    "filter": {
      "conditions": [{
        "field": "session.$Anything.$lib$session",
        "function": "equal",
        "params": ["iOS"]
      }]
    }
  }],
  "by_fields": ["session.$Anything.$element_id$session", "session.$Anything.$lib$session"],
  "filter": {
    "relation":"and",
    "conditions": [{
      "field": "session.$Anything.$lib$session",
      "function": "equal",
      "params": ["iOS"]
    }, {
      "field": "session.$Anything.$element_id$session",
      "function": "isSet",
      "params": []
    }]
  },
  "from_date": "2021-11-30",
  "to_date": "2021-11-30",
  "unit": "day",
  "detail_and_rollup":true,
  "sampling_factor":64,
  "approx":true,
  "hll_precision":12,
  "approx_total":false,
  "limit":1000,
  "use_cache":true
}
'

3.3. Funnel analysis report

[POST /funnels/report]

{
// 漏斗 ID,如何获取漏斗 ID 可以参见 API 常见问题。 "funnel_id": 158,
// 起始日期 "from_date": "2021-07-15",
// 结束日期 "to_date": "20121-07-18",
  // 筛选条件,具体可见本文 2.2 筛选表达式。 "filter": { "conditions": [ { "field": "event.$AppStart.$lib_version", "function": "contain", "params": [ "0.1.0" ] }, { "field": "event.$AppEnd.$lib", "function": "contain", "params": [ "python" ] }, { "field": "user.Gender", "function": "equal", "params": [ "男" ] } ], "relation": "and" },
// (可选)分组属性,按指定步骤事件属性、用户属性或分群名进行分组 "by_field": "event.$AppStart.$os",
// 是否限制漏斗所有步骤在事件窗口内,true:不限制,false:限制(将首步骤之后的步骤的发生时间限定在时间区间内) "extend_over_end_date": true,
 // (可选)分组的步骤 id,如果为 -1 表示用户属性/分群名,0 表示第一步骤事件属性,
// 若 ”by_field” 中能明确看出为第几步的事件属性/用户属性,则此参数可以不用配置。否则需要配置相应参数值,并且和 ”by_field” 请求参数保持一致 "by_field_step": -1,
//(可选)抽样因子,64为全量,32为2分之1抽样 "sampling_factor": 64,
//(可选)指定筛选条件针对的步骤,0 为第一步骤,-1 为用筛选条件为用户属性/用户分群。
// 在请求参数中 "filter" "conditions"中 “field”中指定了每一步骤的事件名及筛选条件,”filter_field_steps”参数可以不用配置。
// 如果配置此参数,需要和 “field” 请求参数中的步骤保持一致。 "filter_field_steps": [ 0, 1, -1 ] }
{
// 漏斗日期聚合数据列表,有几个日期下面就会有几个 steps。该漏斗结果有 4 个 steps
"date_list": [
"$ALL",
"2021-07-15",
"2021-07-16",
"2021-07-17"
],
// 漏斗转化情况详细信息,按照日期进行详细展示,几个 steps 就代表漏斗按照时间聚合有几个对应的日期+合计。date_list 有几个值就有几个 steps,并且按照 date_list 的顺序展示。
"funnel_detail": [
{
// 每个 steps 包含具体某个日期及日期对应的每个步骤的转化详情(包含人数、转化率、流失人数、转化时间中位数)。
// steps 里包含转化及流失情况。
"steps": [
{
// 漏斗第一步转化详情
"event_name": "ViewHomePage", // 漏斗第一步事件名
"converted_user": 98726, // 漏斗第一步总体人数
"conversion_rate": 100, // 该处为固定值 100
"rows": [
{
// 总体 【合计】 转化详情
"converted_user": 76110, // 第一步总体人数
"conversion_rate": 77.09, // 第一步的转化率
"wastage_user": 22616, // 第一步的流失人数
"median_converted_time": 1505 // 转化时间中位数,单位是秒
},
{
// 具体分组值 【合计】 转化详情
"converted_user": 76110, // 第一步总体人数
"conversion_rate": 77.09, // 第一步的转化率
"wastage_user": 22616, // 第一步流失人数
"median_converted_time": 1505 // 转化时间中位数,单位是秒
}
]
},
{
// 漏斗第二步转化详情,具体参数同上
"event_name": "ViewProduct",
"converted_user": 76110,
"conversion_rate": 77.09,
"rows": [
{
"converted_user": 21266,
"conversion_rate": 27.94,
"wastage_user": 54844,
"median_converted_time": 2530
},
{
"converted_user": 21266,
"conversion_rate": 27.94,
"wastage_user": 54844,
"median_converted_time": 2530
}
]
},
{
// 漏斗第三步转化详情,具体参数同上。
"event_name": "SubmitOrder",
"converted_user": 21266,
"conversion_rate": 27.94,
"rows": [
{
"converted_user": 17522,
"conversion_rate": 82.39,
"wastage_user": 3744,
"median_converted_time": 939
},
{
"converted_user": 17522,
"conversion_rate": 82.39,
"wastage_user": 3744,
"median_converted_time": 939
}
]
},
{
// 漏斗最后一步事件名及转化数据情况
"event_name": "PayOrder",
"converted_user": 17522,
"conversion_rate": 82.39,
"rows": []
}
],
// 漏斗总体转化详情
// 漏斗总体转化率
"completion_rate": 17.75,
// 【总体】具体步骤转化详情,依次是第一步人数、第一步转化情况、第二步转化情况、第三步转化详情
"overview": [
[
{
"converted_user": 98726, // 漏斗第一步总人数
"conversion_rate": 100, // 固定值 100
"completion_rate": 100 // 固定值 100
},
{
"converted_user": 76110, // 漏斗第二步人数
"conversion_rate": 77.09, // 漏斗第一步转化率
"completion_rate": 77.09 // 漏斗第一步流失率
},
{
"converted_user": 21266, // 漏斗第三步人数
"conversion_rate": 27.94, // 漏斗第二步人转化率
"completion_rate": 21.54 // 漏斗第二步流失率
},
{
"converted_user": 17522, // 漏斗第四步人数
"conversion_rate": 82.39, // 漏斗第三步人转化率
"completion_rate": 17.75 // 漏斗第三步流失率
}
],
// 具体分组值【总体】转化步骤详情,依次是第一步人数、第一步转化详情、第二步转化详情、第三步转化详情
[
{
"converted_user": 98726,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 76110,
"conversion_rate": 77.09,
"completion_rate": 77.09
},
{
"converted_user": 21266,
"conversion_rate": 27.94,
"completion_rate": 21.54
},
{
"converted_user": 17522,
"conversion_rate": 82.39,
"completion_rate": 17.75
}
]
]
},
// 具体日期对应的具体步骤转化详情,依次是第一步的转化详情、第二步的转化详情、第三步转化详情
{
"steps": [
{
// 具体日期对应的具体步骤转化详情,依次是【总体】里的第一天、具体分组值里的第一天
"event_name": "ViewHomePage", // 第一个事件
"converted_user": 34099, // 第一天第一步人数
"conversion_rate": 100, // 该处固定值 100
"rows": [
{
// 【总体】里第一个日期的转化详情
"converted_user": 26813, // 第一天第一步人数
"conversion_rate": 78.63, // 第一天第一步转化率
"wastage_user": 7286, // 第一天第一步流失人数
"median_converted_time": 1537 // 第一天第一步转化人数中位数
},
{
// 【分组值】里第一个日期的转化详情
"converted_user": 26813,
"conversion_rate": 78.63,
"wastage_user": 7286,
"median_converted_time": 1537
}
]
},
{
"event_name": "ViewProduct",
"converted_user": 26813,
"conversion_rate": 78.63,
"rows": [
{
"converted_user": 7787,
"conversion_rate": 29.04,
"wastage_user": 19026,
"median_converted_time": 2710
},
{
"converted_user": 7787,
"conversion_rate": 29.04,
"wastage_user": 19026,
"median_converted_time": 2710
}
]
},
{
"event_name": "SubmitOrder",
"converted_user": 7787,
"conversion_rate": 29.04,
"rows": [
{
"converted_user": 6449,
"conversion_rate": 82.82,
"wastage_user": 1338,
"median_converted_time": 942
},
{
"converted_user": 6449,
"conversion_rate": 82.82,
"wastage_user": 1338,
"median_converted_time": 942
}
]
},
{
"event_name": "PayOrder",
"converted_user": 6449,
"conversion_rate": 82.82,
"rows": []
}
],
// 具体日期对应的转化详情,依次是【总体】里的某天详情、具体分组里的某天详情
"completion_rate": 18.91,
"overview": [
[
{
"converted_user": 34099,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 26813,
"conversion_rate": 78.63,
"completion_rate": 78.63
},
{
"converted_user": 7787,
"conversion_rate": 29.04,
"completion_rate": 22.84
},
{
"converted_user": 6449,
"conversion_rate": 82.82,
"completion_rate": 18.91
}
],
[
{
"converted_user": 34099,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 26813,
"conversion_rate": 78.63,
"completion_rate": 78.63
},
{
"converted_user": 7787,
"conversion_rate": 29.04,
"completion_rate": 22.84
},
{
"converted_user": 6449,
"conversion_rate": 82.82,
"completion_rate": 18.91
}
]
]
},
// 具体日期对应的具体步骤转化详情,依次是第一个步的转化详情、第二个步的转化详情、第三步转化详情,具体参数意义同上。
{
"steps": [
{
"event_name": "ViewHomePage",
"converted_user": 34445,
"conversion_rate": 100,
"rows": [
{
"converted_user": 26701,
"conversion_rate": 77.52,
"wastage_user": 7744,
"median_converted_time": 1521
},
{
"converted_user": 26701,
"conversion_rate": 77.52,
"wastage_user": 7744,
"median_converted_time": 1521
}
]
},
{
"event_name": "ViewProduct",
"converted_user": 26701,
"conversion_rate": 77.52,
"rows": [
{
"converted_user": 7407,
"conversion_rate": 27.74,
"wastage_user": 19294,
"median_converted_time": 2594
},
{
"converted_user": 7407,
"conversion_rate": 27.74,
"wastage_user": 19294,
"median_converted_time": 2594
}
]
},
{
"event_name": "SubmitOrder",
"converted_user": 7407,
"conversion_rate": 27.74,
"rows": [
{
"converted_user": 6111,
"conversion_rate": 82.5,
"wastage_user": 1296,
"median_converted_time": 956
},
{
"converted_user": 6111,
"conversion_rate": 82.5,
"wastage_user": 1296,
"median_converted_time": 956
}
]
},
{
"event_name": "PayOrder",
"converted_user": 6111,
"conversion_rate": 82.5,
"rows": []
}
],
"completion_rate": 17.74,
"overview": [
[
{
"converted_user": 34445,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 26701,
"conversion_rate": 77.52,
"completion_rate": 77.52
},
{
"converted_user": 7407,
"conversion_rate": 27.74,
"completion_rate": 21.5
},
{
"converted_user": 6111,
"conversion_rate": 82.5,
"completion_rate": 17.74
}
],
[
{
"converted_user": 34445,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 26701,
"conversion_rate": 77.52,
"completion_rate": 77.52
},
{
"converted_user": 7407,
"conversion_rate": 27.74,
"completion_rate": 21.5
},
{
"converted_user": 6111,
"conversion_rate": 82.5,
"completion_rate": 17.74
}
]
]
},
// 具体日期对应的具体步骤转化详情,依次是第一步的转化详情、第二步的转化详情、第三步转化详情,具体参数意义同上。
{
"steps": [
{
"event_name": "ViewHomePage",
"converted_user": 33579,
"conversion_rate": 100,
"rows": [
{
"converted_user": 25271,
"conversion_rate": 75.26,
"wastage_user": 8308,
"median_converted_time": 1485
},
{
"converted_user": 25271,
"conversion_rate": 75.26,
"wastage_user": 8308,
"median_converted_time": 1485
}
]
},
{
"event_name": "ViewProduct",
"converted_user": 25271,
"conversion_rate": 75.26,
"rows": [
{
"converted_user": 6845,
"conversion_rate": 27.09,
"wastage_user": 18426,
"median_converted_time": 2469
},
{
"converted_user": 6845,
"conversion_rate": 27.09,
"wastage_user": 18426,
"median_converted_time": 2469
}
]
},
{
"event_name": "SubmitOrder",
"converted_user": 6845,
"conversion_rate": 27.09,
"rows": [
{
"converted_user": 5599,
"conversion_rate": 81.8,
"wastage_user": 1246,
"median_converted_time": 928
},
{
"converted_user": 5599,
"conversion_rate": 81.8,
"wastage_user": 1246,
"median_converted_time": 928
}
]
},
{
"event_name": "PayOrder",
"converted_user": 5599,
"conversion_rate": 81.8,
"rows": []
}
],
"completion_rate": 16.67,
"overview": [
[
{
"converted_user": 33579,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 25271,
"conversion_rate": 75.26,
"completion_rate": 75.26
},
{
"converted_user": 6845,
"conversion_rate": 27.09,
"completion_rate": 20.38
},
{
"converted_user": 5599,
"conversion_rate": 81.8,
"completion_rate": 16.67
}
],
[
{
"converted_user": 33579,
"conversion_rate": 100,
"completion_rate": 100
},
{
"converted_user": 25271,
"conversion_rate": 75.26,
"completion_rate": 75.26
},
{
"converted_user": 6845,
"conversion_rate": 27.09,
"completion_rate": 20.38
},
{
"converted_user": 5599,
"conversion_rate": 81.8,
"completion_rate": 16.67
}
]
]
}
],
// 分组
"by_field": "event.$Anything.$os",
// 分组值结果 $ALL 代表整体,iOS 代表分组的具体值
"by_values": [
"$ALL",
"iOS"
],
// 漏斗步骤里对应的事件,依次为第一个事件、第二个事件、第三个事件、第四个事件
"event_names": [
"ViewHomePage",
"ViewProduct",
"SubmitOrder",
"PayOrder"
],
// 全量缓存更新时间
"report_update_time": "2021-07-19 19:13:47.703",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2021-07-19 19:12:56.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2021-07-19 19:12:56.000",
// 查询是否截断
"truncated": false,
// 抽样系数
"sampling_factor": 64,
"is_done": true
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/funnels/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \

--data-binary '

{ "funnel_id": 158,  "from_date": "2021-07-15",  "to_date": "20121-07-18",  "filter": { "conditions": [ { "field": "event.$AppStart.$lib_version",  "function": "contain",  "params": [ "0.1.0" ] }, { "field": "event.$AppEnd.$lib",  "function": "contain",  "params": [ "python" ] }, { "field": "user.Gender",  "function": "equal",  "params": [ "男" ] } ], "relation": "and" }, "by_field": "event.$AppStart.$os",  "extend_over_end_date": true,  "by_field_step": -1,  "sampling_factor": 64,  "filter_field_steps": [ 0,  1,  -1 ] }

'



3.4.  Retained analysis report

[POST /retentions/report]

{
// 起始日期
"from_date": "2021-07-19",
// 结束日期
"to_date": "2021-07-20",
// 表示获取往后 N 个单位的留存
"duration": "7",
// 第一个事件的信息
"first_event": {
// 事件名
"event_name": "login"
},
// 第二个事件的信息
"second_event": {
// 事件名
"event_name": "submitOrder",
// 事件的筛选条件
"filter": {
"conditions": [
{
"field": "event.submitOrder.$lib",
"function": "equal",
"params": [
"Android"
]
}
],
"relation":"and"
}
},
// (可选)同时显示第三个指标
"measures": [
{
"event_name": "payOrder",
"aggregator": "unique"
}
],
// (可选)用户的筛选条件
"user_filter": {
"conditions": [
{
"field": "user.sex",
"function": "equal",
"params": [
"男"
]
}
],
"relation":"and"
},
// (可选)时间标识,例如上周,优先级高于 from_date 和 to_date
"rangeText": "上周",
// (可选)留存的单位,可以是 day/week/month
"unit": "day",
// (可选)后续事件是否可以超出时间区间
"extend_over_end_date": true,
// (可选)抽样因子,64为全量,32为2分之1抽样
"sampling_factor": 64,
// (可选)是否计算流失,false为计算留存,true为计算流失
"is_wastage": false,
//(可选)使用缓存,若缓存中找不到相应数据,则从数据库读出
"use_cache": true
}
{
// 表示分组字段值,如果如下为空,代表请求参数里没有选择按照分组查看。
"by_field": "",
"by_fields": [
],
//
"has_first_day": false,
// 查询结果的具体值展示,第一行是总体、第二行开始依次是具体日期的详细数据
"rows": [
{
// 第一行也就是【总体】留存数据详情,$ALL 代表总体。
"by_value": "$ALL",
"by_values": [
"$ALL"
]
,
"total_people": 95, // 初始行为总人数
// cells 里包含的是具体每日的留存数据情况,如果选择了第 0 日,从第 0 日开始依次是第 0 日、第 1 日等每日的留存数据。
"cells": [
{
// 第 0 日的留存数据
"people": 36, // 留存人数
"percent": 37.89, // 留存率
// 选择同时显示后,values 的值即为同时显示的指标的值
"values": [
0
]
},
{
// 第 1 日的留存数据
"people": 6, // 留存人数
"percent": 6.32, // 留存率
// 选择同时显示后,values 的值即为同时显示的指标的值
"values": [
5
]
}
]
},
{
// 第二行的数据也就是【具体日期】留存数据详情,具体参数的含义同上。
"by_value": "2021-07-19",
"by_fields": [
"2021-07-19"
],
"total_people": 91,
"cells": [
{
"people": 25,
"percent": 27.47,
"values": [
0
]
},
{
"people": 1,
"percent": 1.1,
"values": [
1
]
}
]
},
{
"by_value": "2021-07-20",
"by_fields": [
"2021-07-20"
],
"total_people": 62,
"cells": [
{
"people": 25,
"percent": 40.32,
"values": [
0
]
}
]
}
],
// 全量缓存更新时间
"report_update_time": "2021-07-19 17:00:21.355",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2021-07-19 16:59:43.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2021-07-19 16:59:43.000",
// 查询是否截断
"truncated": false,
// 抽样系数
"sampling_factor": 64,
//
"is_done": true
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/retentions/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
"from_date": "2021-07-19",
"to_date": "2021-07-20",
"duration": "7",
"first_event": {
"event_name": "login"
},
"second_event": {
"event_name": "submitOrder",
"filter": {
"conditions": [
{
"field": "event.submitOrder.$lib",
"function": "equal",
"params": [
"Android"
]
}
],
"relation": "and"
}
},
"measures": [
{
"event_name": "payOrder",
"aggregator": "unique"
}
],
"user_filter": {
"conditions": [
{
"field": "user.sex",
"function": "equal",
"params": [
"男"
]
}
],
"relation": "and"
},
"unit": "day",
"extend_over_end_date": true,
"sampling_factor": 64,
"is_wastage": false,
"use_cache": true
}

'

3.5. Distribution analysis report

[POST /addictions/report]

{
// 事件名称
"event_name": "submitOrder",
// 起始时间
"from_date": "2021-07-18",
// 结束时间
"to_date": "2021-07-19",
// 事件筛选条件
"filter": {
"conditions": [
{
"field": "event.submitOrder.$lib",
"function": "equal",
"params": [
"Android"
]
}
],
"relation":"and"
},
// 用户筛选条件
"user_filter": {
"conditions": [
{
"field": "user.sex",
"function": "equal",
"params": [
"男"
]
}
],
"relation":"and"
},
// (可选)时间标识,如:上周,优先级高于from_date、to_date
"rangeText":"上周",
// 抽样因子,64为全量,32为2分之1抽样
"sampling_factor":64,
// 事件单位,可以是 day/week/month
"unit": "day",
// 测量类型,可以是times/period, period是当按小时数或者天数进行分布分析时使用
"measure_type":"times",
//测量类型如果是times,即可以自定义分桶,可省略
"result_bucket_param": [
2,
3
]
}
{
// 表示分组,如果如下“”代表是按照总体查看,没有添加分组查看。
"by_field": "",
// 查询结果的具体值展示,按照日期从小到大依次展示具体日期的详细数据,如 2021-07-18、2021-07-19。
"rows": [
{
// 具体日期的数据分布情况
"by_value": "2021-07-18",
"total_people": 455, // 触发了所分析事件的人数
// cells 里包含的是具体每日的分布数据详情
"cells": [
{
"people": 436, // 该分布区间内人数,如:1~2(不包含 2 )的人数
"percent": 95.82, // 分布区间内人数占总人数比例
"bucket_start": 1, // 分布区间左值
"bucket_end": 2 // 分布区间右值(不包含右值)
},
{
"people": 19, // 该分布区间内人数,如:2~3(不包含 3 )的人数
"percent": 4.18, // 分布区间内人数占总人数比例
"bucket_start": 2, // 分布区间左值
"bucket_end": 3 // 分布区间右值(不包含右值)
}
]
},
{
// 具体日期的数据分布情况,具体参数信息同上
"by_value": "2021-07-19",
"total_people": 280,
"cells": [
{
"people": 273,
"percent": 97.5,
"bucket_start": 1,
"bucket_end": 2
},
{
"people": 7,
"percent": 2.5,
"bucket_start": 2,
"bucket_end": 3
}
]
}
],
// 全量缓存更新时间
"report_update_time": "2021-07-19 17:15:26.739",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2021-07-19 17:14:10.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2021-07-19 17:14:10.000",
// 查询是否截断
"truncated": false,
// 抽样因子,64为全量,32为2分之1抽样
"sampling_factor": 64,
//
"is_done": true

}

curl 'https://golddemo.cloud.sensorsdata.cn/api/addictions/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
"event_name": "submitOrder",
"from_date": "2021-07-18",
"to_date": "2021-07-19",
"filter": {
"conditions": [
{
"field": "event.submitOrder.$lib",
"function": "equal",
"params": [
"Android"
]
}
],
"relation": "and"
},
"user_filter": {
"conditions": [
{
"field": "user.sex",
"function": "equal",
"params": [
"男"
]
}
],
"relation": "and"
},
"sampling_factor": 64,
"unit": "day",
"measure_type": "times",
"result_bucket_param": [
2,
3
]
}

'

3.6. User path analysis report

[POST /path/analytics/report]

{
// 选择起始事件或者结束事件,起始事件是initial_event, 结束事件是termination_event
"source_type": "initial_event",
// 起始/结束事件及对起始/结束事件的条件筛选过滤
"source_event": {
"event_name": "StartApp", // 起始事件
// 起始事件的筛选条件,筛选条件可以设置多种,可以参考本章 2.2 内容
"filter": {
"conditions": [
{
"field": "event.StartApp.$wifi",
"function": "isTrue",
"params": []
}
]
}
},
// 参与分析的事件
"event_names": [
"BuyBullion",
"BuyGold",
"SaleGold",
"StartApp"
],
// 事件分组,可以按照所选择的参与事件的属性进行分组
"by_fields": [
"event.BuyBullion.$country"
],
// (可选)列数量的限制
"col_limit": 20,
// (可选)每列节点数限制
"row_limit": 7,
// 查询开始时间
"from_date": "2017-05-01",
// 查询结束时间
"to_date": "2017-05-22",
// (可选)用户筛选条件,可选用户属性、用户分群、用户标签作为筛选条件
"user_filter": {},
// (可选)事件分组,所选择分组的事件属性如果是数值型的可以进行自定义分组展示数据,为空的话是默认区间
"bucket_params": {},
// 抽样因子,64为全量,32为2分之1抽样
"sampling_factor": 64,
// session 间隔时间
"session_interval": 1200,
//(可选)使用缓存,若缓存中找不到相应数据,则从数据库读出
"use_cache": true
}
{
// nodes 代表节点,节点里每个大括号里代表一层,如下一共是五层,id 里 0 代表第一层
"nodes": [
// 第一层里数据详情
[
{
"id": "0_StartApp", // 0 代表第一层
"event_name": "StartApp", // 第一层里的事件
"times": 27336 // 会话数
}
],
// 第二层里数据详情,具体参数含义同上,多个 id 代表该层油多个节点
[
{
"id": "1_StartApp",
"event_name": "StartApp",
"times": 163
},
{
"id": "1_BuyGold",
"event_name": "BuyGold",
"times": 118
},
{
"id": "1_SaleGold",
"event_name": "SaleGold",
"times": 104
},
{
"id": "1_BuyBullion_$country_3392903",
"event_name": "BuyBullion",
"times": 37
}
],
// 第三层里数据详情,具体参数含义同上,多个 id 代表该层油多个节点
[
{
"id": "2_SaleGold",
"event_name": "SaleGold",
"times": 68
},
{
"id": "2_BuyGold",
"event_name": "BuyGold",
"times": 50
},
{
"id": "2_BuyBullion_$country_3392903",
"event_name": "BuyBullion",
"times": 18
},
{
"id": "2_StartApp",
"event_name": "StartApp",
"times": 2
}
],
// 第四层里数据详情,具体参数含义同上,多个 id 代表该层油多个节点
[
{
"id": "3_SaleGold",
"event_name": "SaleGold",
"times": 39
},
{
"id": "3_BuyGold",
"event_name": "BuyGold",
"times": 23
},
{
"id": "3_BuyBullion_$country_3392903",
"event_name": "BuyBullion",
"times": 1
}
],
// 第五层里数据详情,具体参数同上
[
{
"id": "4_StartApp",
"event_name": "StartApp",
"times": 1
}
]
],
// 每层数据到下一层的流失、留存详情。每个大括号[] 代表一层,如下以第一层为例
"links": [
[
// 第一层到第二层流失留存详情
{
"source": "0_StartApp", // 第一层事件名
"target": "1_wastage", // 到第二层的状态,wastage 代表是流失
"is_wastage": true, // 是否流失,true 代表是
"times": 26914 // 会话数,该处指流失的会话数
},
{
"source": "0_StartApp", // 第一层事件名
"target": "1_StartApp", // 到第二层对应的事件
"times": 163 // 会话数,该处指留存到第二层的会话数
},
{
"source": "0_StartApp", // 第一层事件名
"target": "1_BuyGold", // 到第二层对应的事件
"times": 118 // 会话数,该处指留存到第二层的会话数
},
{
"source": "0_StartApp", // 第一层事件名
"target": "1_SaleGold", // 到第二层对应的事件
"times": 104 // 会话数,该处指留存到第二层的会话数
},
{
"source": "0_StartApp", // 第一层事件名
"target": "1_BuyBullion_$country_3392903", // 到第二层对应的事件
"times": 37 // 会话数,该处指留存到第二层的会话数
}
],
// 第二层到第三层流失留存详情,具体参数同上
[
{
"source": "1_StartApp",
"target": "2_wastage",
"is_wastage": true,
"times": 160
},
{
"source": "1_StartApp",
"target": "2_StartApp",
"times": 2
},
{
"source": "1_StartApp",
"target": "2_BuyBullion_$country_3392903",
"times": 1
},
{
"source": "1_BuyGold",
"target": "2_wastage",
"is_wastage": true,
"times": 68
},
{
"source": "1_BuyGold",
"target": "2_BuyGold",
"times": 50
},
{
"source": "1_SaleGold",
"target": "2_SaleGold",
"times": 68
},
{
"source": "1_SaleGold",
"target": "2_wastage",
"is_wastage": true,
"times": 36
},
{
"source": "1_BuyBullion_$country_3392903",
"target": "2_wastage",
"is_wastage": true,
"times": 20
},
{
"source": "1_BuyBullion_$country_3392903",
"target": "2_BuyBullion_$country_3392903",
"times": 17
}
],
// 第三层到第四层流失留存详情,具体参数同上
[
{
"source": "2_SaleGold",
"target": "3_SaleGold",
"times": 39
},
{
"source": "2_SaleGold",
"target": "3_wastage",
"is_wastage": true,
"times": 29
},
{
"source": "2_BuyGold",
"target": "3_wastage",
"is_wastage": true,
"times": 27
},
{
"source": "2_BuyGold",
"target": "3_BuyGold",
"times": 23
},
{
"source": "2_BuyBullion_$country_3392903",
"target": "3_wastage",
"is_wastage": true,
"times": 17
},
{
"source": "2_BuyBullion_$country_3392903",
"target": "3_BuyBullion_$country_3392903",
"times": 1
},
{
"source": "2_StartApp",
"target": "3_wastage",
"is_wastage": true,
"times": 2
}
],
// 第四层到第五层流失留存详情,具体参数同上
[
{
"source": "3_SaleGold",
"target": "4_wastage",
"is_wastage": true,
"times": 38
},
{
"source": "3_SaleGold",
"target": "4_StartApp",
"times": 1
},
{
"source": "3_BuyGold",
"target": "4_wastage",
"is_wastage": true,
"times": 23
},
{
"source": "3_BuyBullion_$country_3392903",
"target": "4_wastage",
"is_wastage": true,
"times": 1
}
],
// 第五层到第六层流失留存详情,具体参数同上
[
{
"source": "4_StartApp",
"target": "5_wastage",
"is_wastage": true,
"times": 1
}
]
],
// 用户路径各个列的具体信息
"truncate_row": [],
// 列是否有截断
"truncate_col": false,
// 全量缓存更新时间
"report_update_time": "2021-07-19 17:15:26.739",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2021-07-19 17:14:10.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2021-07-19 17:14:10.000",
// 查询是否截断
"truncated": false,
// 抽样因子,64为全量,32为2分之1抽样
"sampling_factor": 64,
// 查询是否完成
"is_done": true

}

curl 'https://golddemo.cloud.sensorsdata.cn/api/path/analytics/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
"source_type": "initial_event",
"source_event": {
"event_name": "StartApp",
"filter": {
"conditions": [
{
"field": "event.StartApp.$wifi",
"function": "isTrue",
"params": []
}
]
}
},
"event_names": [
"BuyBullion",
"BuyGold",
"SaleGold",
"StartApp"
],
"by_fields": [
"event.BuyBullion.$country"
],
"col_limit": 20,
"row_limit": 7,
"from_date": "2021-07-18",
"to_date": "2021-07-19",
"user_filter": {},
"bucket_params": {},
"sampling_factor": 64,
"session_interval": 1200,
"use_cache": true
}

'

3.7. Attribute analysis report

[POST /user/analytics/report]

{
"measures": [
{
"aggregator": "count",
"field": ""
}
],
"filter": {
"conditions": [
{
"field": "user.vip_level",
"function": "isTrue",
"params": []
}
]
},
// 按照属性进行分组展示,可选用户属性、分群、标签。如下选择了两个用户属性作为分组值
"by_fields": [
"user.IncomeLevel",
"user.Gender"
],
"sampling_factor": null,
// 横轴分组指标
"x_axis_field": "user.IncomeLevel",
"use_cache": false
}
{
// 分组值
"by_fields": [
"user.Gender"
],
// 作为横轴的分组指标值
"series": [
"5000~10000",
"3000~5000",
"10000~20000",
"0~3000",
null
],
// 有几列数据,有几个 by_values 值代表有几列,values 值代表的是每个 series 对应的数据,依次对应如下结果值。
"rows": [
// 具体分组值详细信息
{
// values 值代表的是每个 series 对应的数据,依次对应如下结果值。
"values": [
[
83169
],
[
27776
],
[
55699
],
[
27892
],
[
36106
]
],
// by_values 表示分组值
"by_values": [
"男"
]
},
// 具体分组值详细信息
{
"values": [
[
55363
],
[
18208
],
[
37030
],
[
18668
],
[
24090
]
],
"by_values": [
"女"
]
},
// 具体分组值详细信息
{
"values": [
[
25864
],
[
8490
],
[
17327
],
[
8628
],
[
17353
]
],
"by_values": [
null
]
}
],
// 有几个分组值,也就是有几列数据
"num_rows": 3,
// 全量缓存更新时间
"report_update_time": "2021-07-20 14:16:03.595",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2021-07-20 08:00:00.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2021-07-20 08:00:00.000"
// 查询是否截断
"truncated": false,
// 抽样因子,64为全量,32为2分之1抽样
"sampling_factor": 64,
//
"is_done": true

}

curl 'https://golddemo.cloud.sensorsdata.cn/api/user/analytics/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
"measures": [
{
"aggregator": "count",
"field": ""
}
],
"filter": {
"conditions": [
{
"field": "user.HasByGold",
"function": "isTrue",
"params": []
}
]
},
"by_fields": [
"user.IncomeLevel",
"user.Gender"
],
"sampling_factor": null,
"x_axis_field": "user.IncomeLevel",
"request_id": 1495433768121,
"use_cache": false
}

'

3.8. Attribution analysis report

One thing to noteis Attribution analysis reports do not support csv

[POST /attribution/report]

{
// 开始时间
"from_date": "2020-02-01",
// 结束时间
"to_date": "2020-04-15",
// 是否使用缓存
"use_cache": false,
// 直接转化是否参与归因计算
"direct_conversion": true,
// 抽样系数
"sampling_factor": 64,
// 目标事件
"target_event": {
"event_name": "$AppClick",
// 目标事件过滤条件(可选)
"filter": {
"conditions": [
{
// 目标事件属性
"field": "event.$AppClick.$lib",
// 条件的操作符,这里表示等于。支持包含、等于具体使用可以参考:API 通用参数。
"function": "equal",
// 条件的参数,根据不同的操作符可以有一个或者多个。
"params": [
"iOS"
]
}
]

}
},
// 前向事件 可配置多个(可选)
"link_events": [
{
// 前向事件名称
"event_name": "$AppClick",
// 前向事件关联属性
"link_properties": {
// 当前前向事件属性
"current_event_property": "event.$AppClick.$ip",
// 目标事件属性
"target_event_property": "event.$AppClick.$ip"
},
// 前向事件筛选条件
"filter": {}
}
],
// 待归因事件
"attribution_events": {
// 事件集合
"events": [
{
"event_name": "$AppViewScreen"
}
],
// 筛选条件(可选)
"filter": {},
// 分组
"by_fields": [
"event.$Anything.$lib"
]
},
// 筛选条件(可选)
"filter": {
"relation": "and",
"conditions": []
},
// 归因分析模型可选首次触点归因、末次触点归因、线性归因、位置归因、时间衰减归因 ["first","last","linear","position","time_decay"]
"model_type": "first",
// 归因窗口期
"lookback_window": {
// 窗口期单位可选分钟、小时、天 ["minute","hour","day"]
"unit": "day",
"value": 1
}
}
{
"detail_result": {
"rows": [
{
// 没有【待归因事件】 代表【直接转换】,by_values 也会是 null。
"groups": [
{
"by_values": [
null
],
// 待归因事件总点击数
"value": 17,
// 待归因事件转化数量
"converted_number": 17,
// 转化用户数
"converted_user_number": 0,
// 对目标事件的贡献得分
"goal_conversion": 17,
// 对目标事件的贡献度
"conversion_value_rate": 36.96
}
]
},
{
// 待归因事件
"event_name": "$AppViewScreen",
"groups": [
{
"by_values": [
"$iOS"
],
"value": 19,
"converted_number": 13,
"converted_user_number": 1,
"goal_conversion": 29,
"conversion_value_rate": 63.04
}
]
}
]
},
// 全量缓存更新时间
"report_update_time": "2021-07-13 15:16:12.467",
// 查询涉及事件数据的最后更新时间
"data_update_time": "2020-05-10 10:18:48.000",
// 查询涉及事件数据量变化超过 5% 的最后更新时间
"data_sufficient_update_time": "2020-05-10 10:18:48.000",
// 查询是否截断
"truncated": false,
// 抽样因子,64为全量,32为2分之1抽样
"sampling_factor": 64
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/user/analytics/report?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '
{
"from_date": "2020-02-01",
"to_date": "2020-04-15",
"use_cache": false,
"direct_conversion": true,
"sampling_factor": 64,
"target_event": {
"event_name": "$AppClick",
"filter": {
"conditions": [
{
"field": "event.$AppClick.$lib",
"function": "equal",
"params": [
"iOS"
]
}
]

}
},
"link_events": [
{
"event_name": "$AppClick",
"link_properties": {
"current_event_property": "event.$AppClick.$ip",
"target_event_property": "event.$AppClick.$ip"
},
"filter": {}
}
],
"attribution_events": {
"events": [
{
"event_name": "$AppViewScreen"
}
],
"filter": {},
"by_fields": [
"event.$Anything.$lib"
]
},
"filter": {
"relation": "and",
"conditions": []
},
"model_type": "first",
"lookback_window": {
"unit": "day",
"value": 1
}
}

When using curl, note whether the URL is https or http

3.9. LTV analysis report

[POST /ltv/report]

{
  // 起始日期
  "from_date": "2021-07-19",
  // 结束日期
  "to_date": "2021-07-20",
  // 表示获取往后 N 个时间单位的 LTV
  "duration": "90",
  // 初始事件 or 初始时间的信息
  "start_sign": {
    // 初始事件名
    "start_event": "$AppClick",
    // 初始时属性名
    "start_time_field": "user.Gender",
    //(可选)对于起始事件的筛选条件
    "filter": {
      "conditions": [
        {
          // 指标事件属性
          "field": "event.$AppClick.$lib",
          // 筛选条件的操作符,equal 这里表示 等于。此处支持多种,如包含等。具体参考文档开头通用参数
          "function": "equal",
          // 属性的具体值
          "params": [
            "iOS"
          ]
        }
      ]
    }
  },
  "measures": "measures":[
    {
      // 事件名称,特别的,可以使用 $Anything 表示任意事件
      "event_name":"$AppClick",
      // 聚合操作符
      "aggregator":"unique",
      //(可选)对于指标的筛选条件
      "filter": {
        "conditions": [
          {
            // 指标事件属性
            "field": "event.$AppClick.$lib",
            // 筛选条件的操作符,equal 这里表示 等于。此处支持多种,如包含等。具体参考文档开头通用参数
            "function": "equal",
            // 属性的具体值
            "params": [
              "iOS"
            ]
          }
        ]
      }
    }
  ],
  // 时间单位,当前仅支持天
  "unit": "day",
  // (可选)用户的筛选条件
  "filter": {
    "conditions": [
      {
        "field": "user.sex",
        "function": "equal",
        "params": [
          "男"
        ]
      }
    ],
    "relation":"and"
  },
  //(可选)分组属性,可以有零个或者多个
  "by_fields": [
    "event.$AppClick.$screen_width",
    "event.$AppClick.$screen_height"
  ],
  //(可选)分桶条件,对数值型属性进行分组时,可以自定义分桶条件,如果不设置的话,是默认区间
  "bucket_params":{
    "event.$AppClick.$screen_width":[100,200],
    "event.$AppClick.$screen_height":[1000]
  }
}

{
    // 表示分组字段值,如果如下为空,代表请求参数里没有选择按照分组查看。
    "by_fields":[
        "event.$Anything.$screen_width",
        "event.$Anything.$screen_height"
    ],
    // 查询结果的具体值展示
    "rows":[
        {
            // 查询结果,第一行的属性值"1100~1200","1000~1100" 表示第一个分组属性的值、第二个分组属性的值。
            "by_values":[
                "1100~1200",
                "1000~1100"
            ],
            // 符合初始条件的人数
            "total_people":33,
            // ltv 的值
            "cells":[
                {
                    "amount":"2.63", // ltv 值
                    "percent":"0" // ltv 值的占比
                },
                {
                    "amount":"2.78",
                    "percent":"0"
                },
                {
                    "amount":"2.78",
                    "percent":"0"
                },
                {
                    "amount":"2.78",
                    "percent":"0"
                },
                {
                    "amount":"2.97",
                    "percent":"0"
                },
                {
                    "amount":"3.12",
                    "percent":"0"
                },
                {
                    "amount":"3.12",
                    "percent":"0"
                },
                {
                    "amount":"3.12",
                    "percent":"0"
                },
                {
                    "amount":"3.54",
                    "percent":"0"
                },
                {
                    "amount":"4.09",
                    "percent":"0"
                }
            ],
            // 表示具体每个分组的 ltv 信息
            "sub_rows":[
                {
                    "by_value":"event.KH_fxcp_result.$share_depth",
                    "total_people":33,
                    "cells":[
                        {
                            "amount":"2.63",
                            "percent":"0"
                        },
                        {
                            "amount":"2.78",
                            "percent":"0"
                        },
                        {
                            "amount":"2.78",
                            "percent":"0"
                        },
                        {
                            "amount":"2.78",
                            "percent":"0"
                        },
                        {
                            "amount":"2.97",
                            "percent":"0"
                        },
                        {
                            "amount":"3.12",
                            "percent":"0"
                        },
                        {
                            "amount":"3.12",
                            "percent":"0"
                        },
                        {
                            "amount":"3.12",
                            "percent":"0"
                        },
                        {
                            "amount":"3.54",
                            "percent":"0"
                        },
                        {
                            "amount":"4.09",
                            "percent":"0"
                        }
                    ],
                    // 表示具体分组下每一天的 ltv 信息
                    "sub_rows":[
                        {
                            "by_value":"2021-12-05",
                            "total_people":22,
                            "cells":[
                                {
                                    "amount":"2.86",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.04",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.04",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.04",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.32",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.45",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.45",
                                    "percent":"0"
                                },
                                {
                                    "amount":"3.45",
                                    "percent":"0"
                                },
                                {
                                    "amount":"4.09",
                                    "percent":"0"
                                },
                                {
                                    "amount":"4.09",
                                    "percent":"0"
                                }
                            ],
                            "sub_rows":[

                            ]
                        },
                        {
                            "by_value":"2021-12-06",
                            "total_people":11,
                            "cells":[
                                {
                                    "amount":"2.18",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.27",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.27",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.27",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.27",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.45",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.45",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.45",
                                    "percent":"0"
                                },
                                {
                                    "amount":"2.45",
                                    "percent":"0"
                                }
                            ],
                            "sub_rows":[

                            ]
                        }
                    ]
                }
            ]
        }
    ],
  // 全量缓存更新时间
  "report_update_time": "2021-07-19 17:15:26.739",
  // 查询涉及事件数据的最后更新时间
  "data_update_time": "2021-07-19 17:14:10.000",
  // 查询涉及事件数据量变化超过 5% 的最后更新时间
  "data_sufficient_update_time": "2021-07-19 17:14:10.000",
  // 查询是否截断
  "truncated": false,
  // 查询是否完成
  "is_done": true
}


4. User detail query

User Details series interfaces are used to query the list of users in a specific analysis report. Most of the parameters requested are the same as those in the analysis report. New parameters are specified in each interface. The user list also supports JSON and CSV formats. The default format is JSON. If data in CSV format is required, you can manually specify the format parameter. For example, the URL corresponding to the user list for event analysis is in CSV format: /events/user/list? format=csv.

4.1. Event analysis User details report

[POST /events/user/list]

{
"measures": [
{
"aggregator": "unique",
"event_name": "$AppStart",
"name": "App启动的用户数"
}
],
"filter": {
"conditions": [
{
"field": "event.$Anything.$lib",
"function": "equal",
"params": [
"Android"
],
"$$render_index": 1
}
]
},
"by_fields": [
"event.$Anything.$lib"
],
// 查看哪个分组的用户明细
"slice_by_values": [
"Android"
],
// 查询时间范围
"from_date": "2021-07-05",
"to_date": "2021-07-05",
// 汇总日期
"rollup_date": true,
// 时间单位,可以是小时/天/周/月, hour/day/week/month
"unit": "day",
// 指定哪些用户属性,为空表示所有用户属性
"profiles": ["user.$province","user.$signup_time"],

// 是否展示详情,如果 true,则会按照 profile 中的列返回,false 则只返回基本的 id 列
"detail": true,
// 默认值30,表示每页展示用户数,可不加
"num_per_page": 10,
// 请求的页数
"page":1,
// 限制返回的条数
"limit": 10000,
// 是否返回所有用户,如果为 true,则会无视分页参数,否则需要加上分页参数
"all_page": true
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"$signup_time": "2021-06-07 15:04:11.999"2,
"Gender": "男"
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"$signup_time": "2021-06-07 15:04:12.999",
"Gender": "女"
}
}
],
"size": 2,
"page_num": 1, // 页数,总人数/每页展示用户数
"column_name":[
"$signup_time",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/events/user/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{ "measures": [ { "aggregator": "unique",  "event_name": "$AppStart",  "name": "App启动的用户数" } ], "filter": { "conditions": [ { "field": "event.$Anything.$lib",  "function": "equal",  "params": [ "Android" ], "$$render_index": 1 } ] }, "by_fields": [ "event.$Anything.$lib" ], "slice_by_values": [ "Android" ], "from_date": "2021-07-05",  "to_date": "2021-07-05",  "rollup_date": true,  "unit": "day",  "profiles": [ "user.$province",  "user.$signup_time" ], "detail": true,  "num_per_page": 10,  "page": 1,  "limit": 100000,  "all_page": true }

'


4.2. Funnel analysis user details report

[POST /funnels/user/list]

{
"funnel_id": "4", // 漏斗 ID
// 查询时间范围
"from_date": "2021-06-19",
"to_date": "2021-07-18",
// 筛选条件,示例中筛选条件为
"filter": {
"conditions": [
{
"field": "event.$AppStart.$app_version",
"function": "equal",
"params": [
"2.1"
]
},
{
"field": "event.$AppStart.$lib",
"function": "equal",
"params": [
"Android"
]
}
],
"relation": "and" // 多个筛选条件间的关系
},
// 用户明细的分组信息
"by_fields": ["user.$country"],
// 分层属性值
"slice_by_values": ["$ALL"],
// by_fields 数值的下标值为 index ,by_field_steps[index] 代表第 index 个分组值属于第几个 step
"by_field_steps": ["-1"],
"filter_field_steps": ["0","0"],
// 用户明细的步骤,从 0 开始
"slice_step": 0,
// true 表示查看流失用户明细,false 表示转化用户
"slice_wastage_user": false,
// 指定哪些用户属性,为空表示所有用户属性
"profiles": ["user.$province","user.$signup_time"],
// 是否展示详情,如果 true,则会按照 profile 中的列返回,false 则只返回基本的 id 列
"detail": true,
// 请求的页数
"page":1,
// 每页数据条数
"num_per_page": 30,
// 限制返回的条数
"limit": 10000,
// 是否返回所有用户,如果为 true,则会无视分页参数,否则需要加上分页参数
"all_page": true
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"$province": "四川省",
"$signup_time": "2021-06-07 15:04:12.999'
}
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"$province": "甘肃省",
"$signup_time": "2021-06-07 15:04:11.999"
}
}
],
"size": 2,
"page_num": 1,
"column_name":[
"$signup_time",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/funnels/user/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{ "funnel_id": "4",  "from_date": "2021-06-19",  "to_date": "2021-07-18",  "filter": { "conditions": [ { "field": "event.$AppStart.$app_version",  "function": "equal",  "params": [ "2.1" ] }, { "field": "event.$AppStart.$lib",  "function": "equal",  "params": [ "Android" ] } ], "relation": "and" }, "by_fields": [ "user.$country" ], "slice_by_values": [ "$ALL" ], "by_field_steps": [ "-1" ], "filter_field_steps": [ "0",  "0" ], "slice_step": 0,  "slice_wastage_user": false,  "profiles": [ "user.$province",  "user.$signup_time" ], "detail": true,  "page": 1,  "num_per_page": 30,  "limit": 100000,  "all_page": true }

'

4.3. Maintain analytical user detail reports

[POST /retentions/user/list]

{
// 初始行为事件
"first_event": {
"event_name": "$AppViewScreen",
// 初始事件的筛选条件
"filter": {
"conditions": [
{
"field": "event.$AppStart.$app_version",
"function": "equal",
"params": [
"2.1"
]
}
]
}
},
// 后续行为事件
"second_event": {
"event_name": "$AppViewScreen"
},
//是否流失用户,默认留存用户,false 为留存,true 为流失
"is_wastage": false,
// 指定哪些用户属性,为空表示所有用户属性
"profiles": ["user.$province","user.$signup_time"],
// 查询 N 日留存/流失
"duration": 7,
// 查询时间范围
"from_date": "2021-07-05",
"to_date": "2021-07-18",
// 时间单位,可以是小时/天/周/月, hour/day/week/month
"unit": "day",
// 用户明细分的分组值,此示例中是指按初始行为事件的 $app_version 这个事件属性分组,分组值为 2.1
"by_events": ["first"],

"by_field": "event.$AppStart.$app_version",
"slice_by_value": "2.1",
// 查看第几天留存的用户明细,0 表示当天,null 表示全部
// 表示随后第几天留存
"slice_interval": 0,
// 是否展示详情,如果 true,则会按照 profile 中的列返回,false 则只返回基本的 id 列
"detail": true,
// 请求的页数
"page":1,
// 每页数据条数
"num_per_page": 30,
// 限制返回的条数
"limit": 10000,
// 是否返回所有用户,如果为 true,则会无视分页参数,否则需要加上分页参数
"all_page": true
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"$province": "四川省",
"$signup_time": "2021-06-07 15:04:12.999"
}
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"$province": "甘肃省",
"$signup_time": "2021-06-07 15:04:11.999"
}
}
],
"size": 2,
"page_num": 1,
"column_name":[
"$signup_time",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/retentions/user/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{ "first_event": { "event_name": "$AppStart",  "filter": { "conditions": [ { "field": "event.$AppStart.$app_version",  "function": "equal",  "params": [ "2.1" ] } ] } }, "second_event": { "event_name": "$AppViewScreen" }, "is_wastage": false,  "profiles": [ "user.$utm_medium",  "user.$update_time" ], "duration": 7,  "from_date": "2021-07-05",  "to_date": "2021-07-18",  "unit": "day",  "by_events": [ "first" ], "by_field": "event.$AppStart.$app_version",  "slice_by_value": "2.1",  "slice_interval": 0,  "detail": true,  "page": 1,  "num_per_page": 30,  "limit": 100000,  "all_page": true }

'

4.4. Distributed analysis user details report

[POST /addictions/user/list]

{
"event_name": "$AppStart",
//属性筛选条件,此示例中筛选的事件属性 $app_version = 2.1
"filter": {
"conditions": [
{
"field": "event.$Anything.$app_version",
"function": "equal",
"params": [
"2.1"
]
}
]
},
// 是否合计数据
"rollup_date": false,
// 是否明细数据
"detail": true,
// 查询时间范围
"from_date": "2021-01-20",
"to_date": "2021-07-18",
// 时间单位,可以是小时/天/周/月, hour/day/week/month
"unit": "day",
// 用户明细列表的分组信息,此示例中是按 $app_version 属性分组,分组值为 2.1 的用户列表
"by_field": "event.$Anything.$app_version",
"slice_by_value": "2.1",
// 查看事件触发次数为多少的用户明细列表,此示例中是查询的 $AppStart 事件的触发次数为 2 的
"slice_freq": 2,
// 指定哪些用户属性,为空表示所有用户属性
"profiles":["user.$city","user.$province","user.$signup_time"],
// 请求的页数
"page":0,
// 每页数据条数
"num_per_page": 30,
// 限制返回的条数
"limit": 10000,
// 是否返回所有用户,如果为 true,则会无视分页参数,否则需要加上分页参数
"all_page": true
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"$city": "德阳市",
"$province": "四川省",
"$signup_time": "2021-06-07 15:04:12.999"
}
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"$city": "嘉峪关市",
"$province": "甘肃省",
"$signup_time":"2021-06-07 15:04:11.999"
}
}
],
"size": 2,
"page_num": 0,
"column_name":[
"$signup_time",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/addictions/user/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{ "event_name": "$AppStart",  "filter": { "conditions": [ { "field": "event.$Anything.$app_version",  "function": "equal",  "params": [ "2.1" ] } ] }, "rollup_date": false,  "from_date": "2021-01-20",  "to_date": "2021-07-18",  "unit": "day",  "by_field": "event.$Anything.$app_version",  "slice_by_value": "2.1",  "slice_freq": 2,  "profiles": [ "user.$city",  "user.$province",  "user.$signup_time" ], "page": 0,  "num_per_page": 30,  "limit": 100000,  "all_page": true }

'

4.5. User list details report

[POST /users/list]

{
"filter": {
"conditions": [
{
// 这里可以任意增加筛选条件
// 可以指定指分群或标签名,如想获取某个分群的用户,则指定 为 'user.fenqun1'
// 也可以指定普通属性名,如 'user.birthday'
// 更多的用法请参考上面的筛选表达式说明
"field": "user.test",
"function": "isTrue"
}
]
},
"profiles": [
// 请求的用户属性列表
"user.$utm_source"
],
// 请求的页数,从 0 开始,0 代表第一页
"page":0,
// 每页数据条数
"num_per_page": 30,
// 限制返回的条数,limit 大于 1W 就会使用功能流输出,无视分页,返回全部数据
"limit": 10000,
// 是否返回所有用户,如果为 true,则会无视分页参数,否则需要加上分页参数
"all_page": true
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"FavoriteFruits": [
"Raspberry",
"Orange"
],
"$name": "陈爍簀",
"IncomeLevel": "3000~5000",
"$city": "德阳市",
"$province": "四川省",
"$signup_time": "2021-06-07 15:04:12.999",
"Gender": "男",
"Age": 20.0
}
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"FavoriteFruits": [
"Cranberry",
"Guava",
"cantaloupe"
],
"$name": "周瀌狙",
"IncomeLevel": "10000~20000",
"$city": "嘉峪关市",
"$province": "甘肃省",
"$signup_time": "2021-06-07 15:04:11.999",
"Gender": "女",
"Age": 20.0
}
}
],
"size": 2,// 每页的数据条数
"page_num": 1,// 请求的页数
//请求的用户属性列表
"column_name":[
"FavoriteFruits",
"$name",
"Age",
"Gender",
"IncomeLevel",
"$signup_time",
"$city",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/users/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
    "filter":{
        "conditions":[
            {
                "field":"user.test",
                "function":"isTrue"
            }
        ]

    }
,
    "profiles":[
        "user.$utm_source"
    ]
,
    "page":0,
    "num_per_page":30,
    "limit":10000,
    "all_page":true
}

'

This interface can also specify the user id to be queried, which can obtain the properties of the specified user.

{
"filter":{
"conditions":[
{
"field":"user.test",
"function":"isTrue"
}
]
},
"users":["1902482830", "3834577070"],// users参数指定的是神策内部的神策 ID(即 events 表中的 user_id 字段和 users 表中的ID 字段)
"profiles":[
"user.$utm_source"
]
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"FavoriteFruits": [
"Raspberry",
"Orange"
],
"$name": "陈爍簀",
"IncomeLevel": "3000~5000",
"$city": "德阳市",
"$province": "四川省",
"$signup_time": "2021-06-07 15:04:12.999",
"Gender": "男",
"Age": 20.0
}
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"FavoriteFruits": [
"Cranberry",
"Guava",
"cantaloupe"
],
"$name": "周瀌狙",
"IncomeLevel": "10000~20000",
"$city": "嘉峪关市",
"$province": "甘肃省",
"$signup_time": "2021-06-07 15:04:11.999",
"Gender": "女",
"Age": 20.0
}
}
],
"size": 2,// 每页的数据条数
"page_num": 1,// 请求的页数
//请求的用户属性列表

"column_name":[
"FavoriteFruits",
"$name",
"Age",
"Gender",
"IncomeLevel",
"$signup_time",
"$city",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/users/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{
"filter":{
"conditions":[
{
"field":"user.test",
"function":"isTrue"
}
]
},
"users":["1902482830", "3834577070"],
"profiles":[
"user.$utm_source"
]
}

'

4.6. User path User details report

[POST /users/list]

{
// 当前节点信息
"slice_element_filter": [
{
"slice_event_name": "AppInstall",// 当前节点事件
"slice_by_value": "Android" // 当前节点分组属性值
}
],
// 后续节点信息
"next_slice_element_filter": [
{
"slice_event_name": "AppInstall",// 后续节点事件
"slice_by_value": "Android" // 后续节点分组属性值
}
], // 合计,后续事件统计和流失不需要这个过滤条件
"session_level": "0", // 当前节点在第几层 从0 开始
"source_type": "initial_event",// 说明是起始事件
// 起始事件信息

"source_event": {
"event_name": "AppInstall",
"filter": {
"conditions": [
{
"field": "event.AppInstall.$wifi",
"function": "isTrue"
}
]
}
},
// 参与分析的事件
"event_names": [
"$AppClick",
"AppInstall",
"$AppStart"
],
// 按照属性进行分组展示
"by_fields":["event.$AppStart.$lib"],
// 指定哪些用户属性,为空表示所有用户属性
"profiles":["user.$province","user.$signup_time"],

"session_interval": "1200",
// 查询时间范围
"from_date": "2021-02-01",
"to_date": "2021-07-19",
// 是否展示详情,如果 true,则会按照 profile 中的列返回,false 则只返回基本的 id 列
"detail": true,
"col_limit": "20", // 最多支持多少行
"row_limit": "7", // 最多支持多少列
"sampling_factor": 64, //(可选)抽样因子,64为全量,32为2分之1抽样
"is_aggregate": "false", // 当前节点是否表示更多
"edge_type": "ALL", // 可以是WASTAGE,RETENTION和ALL,分别表示流失节点,后续事件统计,该节点合计人数
"is_next_aggregate": "false", // 后续节点是否表示更多
"num_per_page": 50, // 每页数据条数
"all_page": true, // 是否返回所有用户
"limit": 1000, // 限制返回条数
"filter": {},
"use_cache": false // 是否使用缓存
}
{
"users": [
{
"id": "1902482830",
"first_id": "23e3ff2a3ff1e1bc",
"second_id": "1696144579",
"profiles": {
"$province": "四川省",
"$signup_time": "2021-03-17 14:58:00"
}
},
{
"id": "3834577070",
"first_id": "51b0fecc44b5c75b",
"second_id": "1602971488",
"profiles": {
"$province": "甘肃省",
"$signup_time": "2021-03-19 14:58:00"
}
}
],
"size": 2,
"page_num": 1,
"column_name":[
"$signup_time",
"$province"
]
}

curl 'https://golddemo.cloud.sensorsdata.cn/api/users/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{ "slice_element_filter": [ { "slice_event_name": "AppInstall",  "slice_by_value": null } ], "next_slice_element_filter": [ { "slice_event_name": "AppInstall",  "slice_by_value": "1" } ], "session_level": "0",  "source_type": "initial_event",  "source_event": { "event_name": "AppInstall",  "filter": { "conditions": [ { "field": "event.AppInstall.$wifi",  "function": "isTrue" } ] } }, "event_names": [ "$AppClick",  "AppInstall",  "$AppStart" ], "profiles": [ "user.$province",  "user.$signup_time" ], "session_interval": "1200",  "from_date": "2021-02-01",  "to_date": "2021-07-19",  "detail": true,  "col_limit": "20",  "row_limit": "7",  "sampling_factor": 64,  "is_aggregate": "false",  "edge_type": "ALL",  "is_next_aggregate": "false",  "num_per_page": 50,  "all_page": true,  "limit": 1000,  "filter": { }, "use_cache": false }

'

4.7. LTV analyzes user detail reports

[POST /users/list]

{
  // 起始日期
  "from_date": "2021-07-19",
  // 结束日期
  "to_date": "2021-07-20",
  // 表示获取往后 N 个时间单位的 LTV
  "duration": "90",
  // 初始事件 or 初始时间的信息
  "start_sign": {
    // 初始事件名
    "start_event": "$AppClick",
    // 初始时属性名
    "start_time_field": "user.Gender",
    //(可选)对于起始事件的筛选条件
    "filter": {
      "conditions": [
        {
          // 指标事件属性
          "field": "event.$AppClick.$lib",
          // 筛选条件的操作符,equal 这里表示 等于。此处支持多种,如包含等。具体参考文档开头通用参数
          "function": "equal",
          // 属性的具体值
          "params": [
            "iOS"
          ]
        }
      ]
    }
  },
  "measures": "measures":[
    {
      // 事件名称,特别的,可以使用 $Anything 表示任意事件
      "event_name":"$AppClick",
      // 聚合操作符
      "aggregator":"unique",
      //(可选)对于指标的筛选条件
      "filter": {
        "conditions": [
          {
            // 指标事件属性
            "field": "event.$AppClick.$lib",
            // 筛选条件的操作符,equal 这里表示 等于。此处支持多种,如包含等。具体参考文档开头通用参数
            "function": "equal",
            // 属性的具体值
            "params": [
              "iOS"
            ]
          }
        ]
      }
    }
  ],
  // 时间单位,当前仅支持天
  "unit": "day",
  // (可选)用户的筛选条件
  "filter": {
    "conditions": [
      {
        "field": "user.sex",
        "function": "equal",
        "params": [
          "男"
        ]
      }
    ],
    "relation":"and"
  },
  //(可选)分组属性,可以有零个或者多个
  "by_fields": [
    "event.$AppClick.$screen_width",
    "event.$AppClick.$screen_height"
  ],
  //(可选)分桶条件,对数值型属性进行分组时,可以自定义分桶条件,如果不设置的话,是默认区间
  "bucket_params":{
    "event.$AppClick.$screen_width":[100,200],
    "event.$AppClick.$screen_height":[1000]
  }
}


5. Customize the list of queries and user actions

5.1. Custom query

[POST /sql/query]

Use SQL to customize queries. See table structure and custom query methods for detailsCustom query Function introduction.

Note: (1) If the queried event is a preset event, then the $sign needs to be escaped with \.

           (2) If the data in the items table is exported, ensure that the system version is 1.15.1646 or later.

  • Parameters + q: 查询的 SQL,例如 SELECT event,time,user_id FROM events LIMIT 10。 + format: 可能的值包括 + csv:默认格式 + json:每行一个 JSON + event_json:导出可以用于直接导入的 Event Track 格式的 Json,1.15 及之后的版本支持,且不支持使用别名(select $utm_source as utm_source ……) + profile_json:导出可以用于直接导入的 Profile Set/Track Signup 格式的 Json,1.15 及之后的版本支持,且不支持使用别名(select $utm_source as utm_source ……) + item_json: 导出可以用户直接导入神策系统的 item_set 格式的 Json,1.15.1646 及之后的版本才支,且不支持使用别名(select $utm_source as utm_source ……) + sql:不直接返回数据,而是翻译为一条可以直接在 Spark/Impala/Hive 里执行的 SQL

q=SELECT * FROM events LIMIT 10

format=json

{"date":"2021-02-01","$utm_medium":"媒介4","$viewport_position":620,"$is_first_time":1,"$ip":"127.0.0.1","$utm_term":"广告词2","$referrer":"referrer2","$viewport_height":1129,"$url_path":"path2","$url":"url2","$share_depth":524,"event":"$pageview","$element_content":"产品概览","$receive_time":1615963982244,"$referrer_host":"host3","$viewport_width":732,"$utm_source":"B站","$lib":"Java","$event_duration":585,"$utm_campaign":"广告3","user_id":-8777352483108746240,"distinct_id":"TcRljcpRJshin2pf","$title":"标题3","$utm_content":"内容1","time":"2021-02-01 10:24:20.149","$resume_from_background":1}
{"date":"2021-02-01","$utm_medium":"媒介2","$viewport_position":690,"$is_first_time":1,"$ip":"127.0.0.1","$utm_term":"广告词4","$referrer":"referrer1","$viewport_height":737,"$url_path":"path1","$url":"url1","$share_depth":1141,"event":"$pageview","$element_content":"在线销售","$receive_time":1615963985088,"$referrer_host":"host3","$viewport_width":847,"$utm_source":"B站","$lib":"Java","$event_duration":152,"$utm_campaign":"广告4","user_id":-775465369173725182,"distinct_id":"23iTvnZ1fEcDkG43","$title":"标题3","$utm_content":"内容1","time":"2021-02-01 13:06:41.599","$resume_from_background":1}
{"date":"2021-02-01","$utm_medium":"媒介4","$viewport_position":1197,"$is_first_time":0,"$ip":"127.0.0.1","$utm_term":"广告词4","$referrer":"referrer1","$viewport_height":708,"$url_path":"path2","$url":"url3","$share_depth":883,"event":"$pageview","$element_content":"道路救援","$receive_time":1615963985506,"$referrer_host":"host3","$viewport_width":46,"$utm_source":"头条","$lib":"Java","$event_duration":540,"$utm_campaign":"广告4","user_id":-1032801030870320381,"distinct_id":"EmFSBmTmYbXUpJOu","$title":"标题1","$utm_content":"内容1","time":"2021-02-01 06:16:29.406","$resume_from_background":1}

The interface and other API call method is different, q parameter can be passed directly with GET/POST parameter, csv format returned data is \t Separated. An example of using curl is as follows:

curl 'https://saasdemo.cloud.sensorsdata.cn/api/sql/query?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \

-X POST \

--data-urlencode "q=SELECT * FROM events LIMIT 10" \

--data-urlencode "format=csv"


5.2. User behavior list

[POST /users/event/list]

Get detailed information about the behavior of one or more users over a period of time.

{
// 需要查询行为序列的用户的 ID
"users": [ "111", "73e51c75edc00593" ], "from_date": "2021-06-04", "to_date": "2021-06-04",
// false 表示 users参数指定的是神策内部的神策 ID(即 events 表中的 user_id 字段和 users 表中的ID 字段);true 表示传入的是 distinct_id
"distinct_id": true }
{
// 用户行为序列中的事件及事件属性 "events": [ { "distinct_id": "111", "user_id": "91956876552221643", "event": "$AppStart", "time": "2021-06-04 11:52:19.091", "properties": { "$ip": "10.90.28.102", "$lib": "Android", "$track_signup_original_id": "73e51c75edc00593", "$country": "保留IP", "$screen_width": 1080, "$screen_orientation": "portrait", "$screen_height": 2340, "$app_name": "Market", "$app_id": "com.sqh.market", "$app_version": "1.0.1", "$os": "Android", "$os_version": "10", "$timezone_offset": -480, "$wifi": 0, "$resume_from_background": 0, "$is_first_day": 0, "$is_first_time": 0, "$province": "保留IP", "$city": "保留IP", "$latitude": 3000000, "$longitude": 4000000, "$network_type": "NULL", "$device_id": "73e51c75edc00593", "$manufacturer": "HUAWEI", "$model": "EBG-AN00", "$carrier": "中国联通", "$screen_name": "com.sqh.market.activity.AnimationActivity", "$title": "Market" }, "profiles": null }, { "distinct_id": "111", "user_id": "91956876552221643", "event": "$AppStart", "time": "2021-06-04 15:54:16.529", "properties": { "$ip": "10.90.28.102", "$lib": "Android", "$track_signup_original_id": "73e51c75edc00593", "$country": "保留IP", "$screen_width": 1080, "$screen_orientation": "portrait", "$screen_height": 2340, "$app_name": "Market", "$app_id": "com.sqh.market", "$app_version": "1.0.1", "$os": "Android", "$os_version": "10", "$timezone_offset": -480, "$wifi": 1, "$resume_from_background": 0, "$is_first_day": 0, "$is_first_time": 0, "$province": "保留IP", "$city": "保留IP", "$latitude": 3000000, "$longitude": 4000000, "$network_type": "WIFI", "$device_id": "73e51c75edc00593", "$manufacturer": "HUAWEI", "$model": "EBG-AN00", "$carrier": "中国联通", "$screen_name": "com.sqh.market.activity.AnimationActivity", "$title": "Market" }, "profiles": null } ] }

curl 'https://golddemo.cloud.sensorsdata.cn/api/users/event/list?token=53f48d27f5ed6e701241d7548093274533d0af3d9d2ae80740a629836897900d&project=default' \
-H 'Content-Type: application/json' \
--data-binary '

{ "users": [ "111",  "73e51c75edc00593" ], "from_date": "2021-06-04",  "to_date": "2021-06-04",  "distinct_id": true }
'

6. Q and A.

6.1. Query API prompt {"error":" No access, please check project and token"}?

First of all: check whether the domain name in the request address is the domain name of the customer system's own system (note:not the domain name of the data receiving address
Second: Check whether project and token are parameters of the same project
Finally: Check whether the token is an API Secret under the admin account or an Access token obtained through your own account password. If it is API Secret, the token is placed directly after the url link. If it is an Access token, the token parameter cannot be placed directly after the url link, but needs to be placed in the Header parameter, that is, add the parameter:
-H 'sensorsdata-token: {got Access token}'
Refer to this document for details:API request address description

6.2. Query engine error

You can check whether the queried API interface corresponds to the parameter name, and whether the parameter format is correct.

6.3. Error API return 422

For API SQL queries, the $sign needs to be translated

6.4. When using background analysis services such as API query or download user list, 504 errors were reported

In the service forwarding configuration, the connection timeout period is not configured or the timeout period is set to a short time. You can change the timeout period. In general, we recommend that the data receiving address timeout period is 60, and the background analysis service timeout period is 1800.

6.5. Can the query API be used to return the query results to the business on the customer line for real-time analysis? What are the limits on the frequency of requests to query the API?

The Sensors query API is only suitable for low-frequency calls, and the corresponding speed depends on the following two aspects:

  1. The actual query scenario: such as the amount of data, the time range of the query data, the analysis model used or the complexity of the SQL, etc.
  2. Hardware and network configuration: CPU, memory, network card, hard disk, etc

Under the premise of matching the query scenario and the server configuration of Shence, Sensors suggests that the API call frequency should be kept at the minute level, the data range of a single query should be within 1 10,000 , and the maximum number of concurrent requests at the same time should not exceed 10. To ensure that the query is appropriate and the service performance is stable. If the conditions are beyond the range described above, response failure, slow query, or even unstable service performance may occur.
The above is given by Sensors based on historical docking experience. Considering the differences in the query call scenarios of different customers, it is recommended to take the actual measurement as the criterion, and reasonably adjust the query conditions and call frequency according to the actual test results.

6.6. How do I get the funnel ID?

Can use API to get funnel list  [GET  /funnels?limit=1000get all funnel information, and then return to the result to get the funnel ID.注意,The limit parameter must be taken.

[ { "update_time": "2018-01-18 11:35:00",  "access": true,  "create_time": "2018-01-18 10:07:17",  "user_name": "admin",  "step_name": [ "APP启动",  "绑定银行卡",  "绑定银行卡成功",  "点击投资",  "提交投资项目",  "投资成功" ], "name": "投资成功留存率-设置筛选条件",  "id": 5, // 漏斗 ID "max_convert_time": 10080 } ]