標籤規則描述

規則描述部分是可嵌套的結構,較為複雜,此處單獨進行描述。 在 「添加」 標籤/使用者群時,會用到規則描述。
rules_\relation_\node: 規則之間的邏輯關係

// 規則間邏輯關係
{
  "type": "rules_relation"
  "relation": string; // and/or
  "rules":[] // 只允許 type 為 "rules_relation" 和三種規則節點,不允許為空
}


rule\_node: 規則節點,分三種

// 屬性規則
{
  "type": "profile_rule",
  "field": string, // 標籤/使用者群或屬性和標籤/使用者群的組合
  "function": string, // 規則函數(指標約束) 
  "params": [] // 規則條件值。List<Object>
}
// 事件規則
{
  "type": "event_rule",
  "measure": {
    "type": "event_measure",
    "event_name": string, // 事件名
    "aggregator": string, // 指標統計方式,如count, sum之類
    "field": string // optional. 某些指標統計方式對應的 field 可以為空
  },
  "time_function": string, // 時間區間函數
  "time_params": [], // 時間區間參數
  "function": string, // 規則函數 (指標約束)
  "params": [], // 規則條件。 不出現指標 
  "filters": [] // 選條件。 可以為空清單,不為空時只有一個元素,filter_relation_node或filter_node
}
// 行为序列规则
{
  "type": "event_sequence_rule",
  "time_function": string, // 行為序列的時間函數
  "time_params": [], // 行為序列的時間區間參數
  "steps":
  [
    {
      "event": string, // 事件名1/虛擬事件
      "filters": [] // 篩選條件,同上
    },
    {
      "event": string, // 事件名2/虛擬事件2
      "filters": [] // 篩選條件,同上
    }
  ]


filter\_realtion\_node: 同一事件的篩選條件的邏輯關係

{
  "type": "filters_relation",
  "relation": string; // and/or
  "subfilters":[] // 只允許type為filters_relation或filter
}


filter\_node: 事件或事件型指標的數據約束

{
  "type": "filter"
  "field": string, // 事件屬性
  "function": string, // 篩選條件函數
  "params": [] // 篩選條件的值
}

規則中使用到的通用參數請參考:通用參數

創建標籤

公開欄位欄位名稱、欄位含義、欄位類型及可選取值:

欄位名

欄位含義

欄位類型

是否必填

可選值

其他說明

id

標籤id

number

0

創建可填 0 ,傳回按照創建順序返回實際標籤 id

name

標籤英文名

string


創建時不填寫則不校驗(預設給個不衝突的 name),如果填寫了則會進行重名校驗

cname

標籤中文名

string


顯示名

comment

標籤備註

string



dir_id

目錄ID

number


標籤所在分組

cron

調度週期

string


cron 運算式 如:0 0 0 ? * 表示每天 0 點計算,如果是單次標籤則可缺省

is_routine

是否是例行標籤

boolean


如果是例行標籤,則上面的cron必填

app_push_list

app push 配置清單

list


用於推送

base_time

標籤計算的基準時間

string


創建時不需填寫(填寫也無效)格式如:"2019-03-05 00:00:00"

unit

標籤更新週期

string

DAY

目前只支援DAY

data_type

標籤數據類型

string

BOOL, NUMBER, STRING, DATETIME,LIST

參考資料格式

source_type

標籤類型

string

1--自定義標籤值
9--基礎指標值
10--首次末次特徵
11--事件偏好屬性
12--行為分佈結果
7--sql創建

規則創建的標籤
註:匯入建立標籤參考:「匯入建立」標籤

[PUT /v2​/user_tags​​]

  • Request (application/json)

自訂標籤值標籤

{
    "id":0,
    "cname":"顯示名稱",
    "name":"user_tag_xianshimingcheng",
    "source_type":1,//1--自定義標籤值 9基礎指標值 10首次末次特徵 11事件偏好屬性 12行為分佈結果 7sql創建
    "is_routine":true,//是否為例行計算
    "unit":"DAY",//最小計算週期,目前僅支援以天為週期的調度
    "dir_id":1,// 目錄ID
    "data_type":"STRING",//標籤數據類型 BOOL(布爾), NUMBER(熟知), STRING(字串), DATETIME(時間), LIST(列表)
    "cron":"0 0 0 * * ? *",// 調度週期,cron 運算式格式,例行計算必填
    "rule_content_list":[// 規則資訊
        {
            "value":"分層1",// 單值的取值
            "type":"rules_relation",//定義規則間的邏輯關係
            "relation":"and",//規則集之間的關係 and/or
            "rules":[// 規則集
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "measure":{
                                "aggregator":"general",
                                "field":"",
                                "type":"event_measure",
                                "event_name":"buy"
                            },
                            "type":"event_rule",
                            "time_function":"relative_time",
                            "time_params":[
                                "1 day"
                            ],
                            "params":[
                                1
                            ],
                            "function":"least",
                            "filters":[

                            ]
                        }
                    ]
                }
            ]
        },
        {
            "value":"分層2",
            "type":"rules_relation",
            "relation":"and",
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"profile_rule",
                            "field":"user.$update_time",
                            "function":"equal",
                            "params":[
                                "10"
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "app_push_list":null,
    "comment":"備註"
}

欄位名

欄位含義

欄位類型

是否必填

可選值

其他說明

relation

規則之間的關係

string

用於自訂標籤值

and/or

規則集之間的關係

rule_content_list

規則資訊

list

必填


[分層1 json,分層2 json,...]

rules

標籤規則

list

必填


參考:標籤規則描述

value

階層名稱

string

用於自訂標籤值


單值的取值,例如"分層1"


基礎指標值標籤

{
	......
    "rule_content_list":[
        {
            "type":"basic_measures",
            "measure":{
                "type":"event_measure",
                "event_name":"ClickBanner",
                "aggregator":"general",// 指標類型--總次數:general,總和:SUM,最大:MAX,最小:MIN,均值:AVG,去重:uniqCount
                "field":""
            },
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"simple_event_rule",
                            "filters":[
                                {
                                    "type":"filter",
                                    "field":"event.WithdrawCash.WithdrawDate",
                                    "function":"greaterequal",
                                    "params":[
                                        "2015-04-01 00:03:00"
                                    ]
                                }
                            ],
                            "time_function":"relative_time",
                            "time_params":[
                                "1,0,hour"
                            ]
                        }
                    ]
                }
            ]
        }
    ],
	......
}

首次末次特徵標籤

{
	......
    "rule_content_list":[
        {
            "type":"first_last_time_feature",
            "measure":{
                "type":"event_measure",
                "event_name":"ClickBanner",
                "aggregator":"first_time", // first_time, last_time, first_time_interval, last_time_interval
                "field":"event.ClickBanner.$time"
            },
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"simple_event_rule",
                            "filters":[
                                {
                                    "type":"filter",
                                    "field":"event.WithdrawCash.WithdrawDate",
                                    "function":"greaterequal",
                                    "params":[
                                        "2015-04-01 00:03:00"
                                    ]
                                }
                            ],
                            "time_function":"relative_time",
                            "time_params":[
                                "1,0,hour"
                            ]
                        }
                    ]
                }
            ]
        }
    ],
	......
}

事件偏好屬性標籤

{
	......
    "rule_content_list":[
        {
            "type":"event_property_preferences",
            "measure":{
                "type":"event_measure",
                "event_name":"ClickBanner",
                "aggregator":"group_concat",
                "field":"event.BuyGold.$city"
            },
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"event_rule",
                            "measure":{
                                "type":"event_measure",
                                "event_name":"ClickBanner",
                                "aggregator":"rank_desc",
                                "field":"event.BuyGold.GoldPrice"
                            },
                            "filters":[
                                {
                                    "type":"filter",
                                    "field":"event.WithdrawCash.WithdrawDate",
                                    "function":"greaterequal",
                                    "params":[
                                        "2015-04-01 00:03:00"
                                    ]
                                }
                            ],
                            "params":[
                                20
                            ],
                            "function":"most",
                            "time_function":"relative_time",
                            "time_params":[
                                "1,0,hour"
                            ]
                        }
                    ]
                }
            ]
        }
    ],
	......
}

行為分佈結果

{
	......
    "rule_content_list":[
        {
            "type":"behavior_distribution_result",
            "measure":{
                "type":"event_measure",
                "event_name":"ClickBanner",
                "aggregator":"uniqcount", // 此處都是 uniqcount 這個值,表示是COUNT(DISTINCT)
                "field":"",
                "unit":"day" // 有 day, hour 兩個值
            },
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"simple_event_rule",
                            "filters":[
                                {
                                    "type":"filter",
                                    "field":"event.WithdrawCash.WithdrawDate",
                                    "function":"greaterequal",
                                    "params":[
                                        "2015-04-01 00:03:00"
                                    ]
                                }
                            ],
                            "time_function":"relative_time",
                            "time_params":[
                                "1,0,hour"
                            ]
                        }
                    ]
                }
            ]
        }
    ],
	......
}


基礎指標指、首次末次特徵、事件偏好屬性、行為分佈結果

欄位名

欄位含義

欄位類型

是否必填

可選值

其他說明

rule_content_list

規則資訊

list

必填



type

標籤創建方式

string

必填

  • event_measure(基礎值標籤)
  • first_last_time_feature(首次末次特徵值標籤)
  • event_property_preferences(事件偏好屬性標籤)
  • behavior_distribution_result(行為分佈結果)


measure

標籤值規則

json

必填



rules

標籤規則

list

必填


參考:標籤規則描述

SQL計算結果標籤

{
    "id":0,
    "cname":"標籤5",
    "name":"user_tag_biaoqian5",
    "source_type":7,
    "is_routine":true,
    "unit":"DAY",//目前僅支援天的維度
    "dir_id":38,
    "data_type":"STRING",
    "cron":"0 0 0 * * ? *",
	"app_push_list":null,
	"comment":"備註",
    "sql":"select id as id,first_id as distinct_id,  $city as value from users"
}


sql 計算結果標籤

欄位名

欄位含義

欄位類型

是否必填

可選值

其他說明

sql

sql規則

string

必填


參考文件:使用 sql 建立使用者分頁

  • Response 200 (application/json)
返回標籤元資訊JSON,JSON資訊請參考獲取標籤元資訊返回結果


獲取標籤元資訊

  • [GET ​/v2/user_tags​/{id}​]

    • Response 200 (application/json)
    {
      "id":15,
      "dir_id":1,// 標籤所在目錄對應的id
      "name":"user_tag_biaoqian12", //標籤名
      "cname":"標籤12", // 標籤顯示名
      "user_name":"xxx@qq.com", // 標籤建立用戶
      "create_time":"2019-12-05 20:46:56", // 標籤建立時間
      "data_type":"STRING", // 標籤資料類型
      "unit":"DAY", // 標籤計算的最小周期,目前UI界面没有,但是調用API可以指定標籤的調度周期
      "source_type":1, // 標籤資料來源類型:1 rule 篩選規則,2 query_result 查詢结果,5 upload 上傳建立,6 import 外部導入,7 SQL sql建立(不使用 0,3,4是為了避免升級操作,用 6 是因为 1.13 的 6 沒有用到)
      "is_routine":true, // 是否為例行,只有 source_type 為 rule/sql 時,例行才是有效的,其他 source_type 均为非例行,無論是否为例行,分群均可具有多個 Partition,只是 例行分群會由系統自動定期建立新Partition
      "status":"RUNNING",// 標籤狀態,pending 待審批,running 正常運行,suspend 已暫停
      "comment":"",// 備註
      "cron":"0 0 0 * * ? *",// 調度周期 
      "rule_content_list":[//多值規則列表
        {
          "value":"分層1",// 單值的取值
          "type":"rules_relation",// 定義規則間的邏輯關係
          "relation":"and",// 關係 and/or
          "rules":[// 規則節點列表
            {
              "type":"rules_relation",
              "relation":"and",
              "rules":[
                {
                  "type":"profile_rule",
                  "field":"user.$first_visit_time",
                  "function":"equal",
                  "params":[
                    "2019-12-10 00:00:00:00"
                  ]
                }
              ]
            },
            {
              "type":"rules_relation",
              "relation":"and",
              "rules":[
                {
                  "measure":{
                    "aggregator":"general",
                    "field":"",
                    "type":"event_measure",
                    "event_name":"buy"
                  },
                  "type":"event_rule",
                  "time_function":"relative_time",
                  "time_params":[
                    "1 day"
                  ],
                  "params":[
                    1
                  ],
                  "function":"least",
                  "filters":[
    
                  ]
                }
              ]
            },
            {
              "type":"rules_relation",
              "relation":"and",
              "rules":[
                {
                  "type":"event_sequence_rule",
                  "time_function":"relative_time",
                  "time_params":[
                    "1 day"
                  ],
                  "steps":[
                    {
                      "event":"buy",
                      "filters":[
    
                      ]
                    },
                    {
                      "event":"buy",
                      "filters":[
    
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "failed_partition_count":0,// 失敗的 partition 數
      "last_succeed_partition":{//最近一次成功計算的partition 資訊
        "base_time":"2019-12-18 00:00:00",// 標籤計算的基準時間 2018-08-28 11:00:00
        "start_time":"2019-12-18 01:00:26",// partition 計算開始時間
        "finished_time":"2019-12-18 01:00:30",// partition 計算結束時間
        "user_count":0, // 這個 partition 的總用户数
        "status":"SUCCEED", // Partition 狀態,新建標籤還未執行:new、執行中:computing、執行成功:succeed、執行失敗:failed
        "rule_content_list":[// 計算規則
          {
            "value":"分層1",
            "type":"rules_relation",
            "relation":"and",
            "rules":[
              {
                "type":"rules_relation",
                "relation":"and",
                "rules":[
                  {
                    "type":"profile_rule",
                    "field":"user.$first_visit_time",
                    "function":"equal",
                    "params":[
                      "2019-12-10 00:00:00:00"
                    ]
                  }
                ]
              },
              {
                "type":"rules_relation",
                "relation":"and",
                "rules":[
                  {
                    "measure":{
                      "aggregator":"general",
                      "field":"",
                      "type":"event_measure",
                      "event_name":"buy"
                    },
                    "type":"event_rule",
                    "time_function":"relative_time",
                    "time_params":[
                      "1 day"
                    ],
                    "params":[
                      1
                    ],
                    "function":"least",
                    "filters":[
    
                    ]
                  }
                ]
              },
              {
                "type":"rules_relation",
                "relation":"and",
                "rules":[
                  {
                    "type":"event_sequence_rule",
                    "time_function":"relative_time",
                    "time_params":[
                      "1 day"
                    ],
                    "steps":[
                      {
                        "event":"buy",
                        "filters":[
    
                        ]
                      },
                      {
                        "event":"buy",
                        "filters":[
    
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      "last_partition_info":{
        "base_time":"2019-12-18 00:00:00",
        "start_time":"2019-12-18 01:00:26",
        "finished_time":"2019-12-18 01:00:30",
        "user_count":0,
        "status":"SUCCEED",
        "next_partition_base_time":"2019-12-19 00:00:00" // 下一次计算的 base_time
      }
    }

    獲取標籤詳情

    [POST /v2​/user_tags​/{id}​/report] 注意:該介面不支援高併發查詢

    • Request (application/json)
    {
      "from_date": "2019-12-16",// 設定時間範圍,開始時間(含),格式:2019-12-16
      "to_date": "2019-12-18",// 設定時間範圍,結束時間(含),格式:2019-12-18
      "bucket_param": [// 分組資訊(同事件分析)。 對於 data_type 為 timestamp 和 number 的標籤支援離散分組,其他類型的標籤只有預設分組0],
      "limit": 0 //对返回的 value 數量進行限制,預設返回 1000 行
    }
    • Response 200 (application/json)
    {
      "aggregate_result":{//所有分層匯總的聚合結果
        "series":[
          "2019-12-16 00:00:00",
          "2019-12-17 00:00:00",
          "2019-12-18 00:00:00"
        ],
        "rows":[
          {
            "by_value":"$ALL",
            "partition_values":[
              {
                "user_count":0, // 用户數量
                "percent":100, // 占比
                "base_time":"2019-12-16 00:00:00", // partition 時間
                "finished_time":"2019-12-16 01:01:37"// 計算完成時間
              },
              {
                "user_count":0,
                "percent":100,
                "base_time":"2019-12-17 00:00:00",
                "finished_time":"2019-12-17 01:00:34"
              },
              {
                "user_count":0,
                "percent":100,
                "base_time":"2019-12-18 00:00:00",
                "finished_time":"2019-12-18 01:01:02"
              }
            ]
          }
        ]
      },
      "non_aggregate_result":{//分別顯示各分層的一天緯度聚合結果
        "series":[
          "2019-12-16 00:00:00",
          "2019-12-17 00:00:00",
          "2019-12-18 00:00:00"
        ],
        "rows":[
          {
            "by_value":"分層2",
            "partition_values":[
              {
                "user_count":0,
                "percent":0,
                "base_time":"2019-12-16 00:00:00",
                "finished_time":"2019-12-16 01:01:37"
              },
              {
                "user_count":0,
                "percent":0,
                "base_time":"2019-12-17 00:00:00",
                "finished_time":"2019-12-17 01:00:34"
              },
              {
                "user_count":0,
                "percent":0,
                "base_time":"2019-12-18 00:00:00",
                "finished_time":"2019-12-18 01:01:02"
              }
            ]
          },
          {
            "by_value":"分層1",
            "partition_values":[
              {
                "user_count":0,
                "percent":0,
                "base_time":"2019-12-16 00:00:00",
                "finished_time":"2019-12-16 01:01:37"
              },
              {
                "user_count":0,
                "percent":0,
                "base_time":"2019-12-17 00:00:00",
                "finished_time":"2019-12-17 01:00:34"
              },
              {
                "user_count":0,
                "percent":0,
                "base_time":"2019-12-18 00:00:00",
                "finished_time":"2019-12-18 01:01:02"
              }
            ]
          }
        ]
      }
    }
  • 更新標籤配置



[PUT /v2​/user_tags​/{id}​]

  • Request (application/json)
//段落註釋見 獲取標籤無訊息 Response
{
    "id":21,
    "dir_id":1,
    "name":"user_tag_xianshimingcheng",
    "cname":"顯示名稱",
    "user_name":"xxx@qq.com",
    "create_time":"2019-12-18 14:42:41",
    "data_type":"STRING",
    "unit":"DAY",
    "source_type":1,
    "is_routine":true,
    "status":"PENDING",
    "comment":"備註",
    "cron":"0 0 0 * * ? *",
    "rule_content_list":[
        {
            "value":"分層1",
            "type":"rules_relation",
            "relation":"and",
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "measure":{
                                "aggregator":"general",
                                "field":"",
                                "type":"event_measure",
                                "event_name":"buy"
                            },
                            "type":"event_rule",
                            "time_function":"relative_time",
                            "time_params":[
                                "1 day"
                            ],
                            "params":[
                                1
                            ],
                            "function":"least",
                            "filters":[

                            ]
                        }
                    ]
                }
            ]
        },
        {
            "value":"分層2",
            "type":"rules_relation",
            "relation":"and",
            "rules":[
                {
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"profile_rule",
                            "field":"user.$update_time",
                            "function":"equal",
                            "params":[
                                "10"
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "failed_partition_count":0,
    "last_succeed_partition":{
        "rule_content_list":[
            {
                "value":"分層1",
                "type":"rules_relation",
                "relation":"and",
                "rules":[
                    {
                        "type":"rules_relation",
                        "relation":"and",
                        "rules":[
                            {
                                "measure":{
                                    "aggregator":"general",
                                    "field":"",
                                    "type":"event_measure",
                                    "event_name":"buy"
                                },
                                "type":"event_rule",
                                "time_function":"relative_time",
                                "time_params":[
                                    "1 day"
                                ],
                                "params":[
                                    1
                                ],
                                "function":"least",
                                "filters":[

                                ]
                            }
                        ]
                    }
                ]
            },
            {
                "value":"分層2",
                "type":"rules_relation",
                "relation":"and",
                "rules":[
                    {
                        "type":"rules_relation",
                        "relation":"and",
                        "rules":[
                            {
                                "type":"profile_rule",
                                "field":"user.$update_time",
                                "function":"equal",
                                "params":[
                                    "10"
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    },
    "last_partition_info":{
        "base_time":"2019-12-18 00:00:00",
        "start_time":"2019-12-18 14:42:41",
        "finished_time":"2019-12-18 14:42:41",
        "user_count":0,
        "status":"NEW",
        "next_partition_base_time":"2019-12-19 00:00:00"
    }
}
  • Response 200 (application/json)
返回标签元信息JSON,JSON信息请参考获取标签元信息返回结果

刪除標籤

[DELETE /v2​/user_tags​/{id}​]

修改標籤的調度狀態

[PATCH ​/v2/user_tags​/{id}​]

  • Request (application/json)
{
    "status":"SUSPEND"// 狀態有 RUNNING(開啟) SUSPEND(暫停) 
}
  • Response 200 (application/json)
返回標籤元資訊JSON,JSON資訊請參考獲取標籤元資訊返回結果


取得所有/部分 partition

[GET ​/v2/user_tags​/{id}​/partitions]


  • Request

    /v2/user_tags​/{id}​/partitions?from_date=2019-12-17&to_date=2019-12-18&start=1&count=10
    参数名是否必填类型描述
    from_dateString 
    • 同時存在from_date 和 to_date 兩個參數按照時間的範圍查詢
    • 如果傳遞其中一個參數,系統會提示異常
    • 沒有傳遞參數則查詢全量partition

    to_dateString
    orderString

    可以传递desc 返回base_time倒序

    startInteger

    查询结果截取参数,start 从1 开始计数,从start开始返回count条数据

    如果数量不足这返回start开始之后的全量数据

    countInteger

    參數名

    是否必填

    類型

    描述

    from_date

    String

    • 同時存在from_date 和 to_date 兩個參數按照時間的範圍查詢
    • 如果傳遞其中一個參數,系統會提示異常
    • 沒有傳遞參數則查詢全量partition|



  • Response 200 (application/json)

    [
        {
            "base_time":"2019-12-17 00:00:00",
            "start_time":"2019-12-17 01:00:46",
            "finished_time":"2019-12-17 01:00:49",
            "user_count":0,
            "status":"SUCCEED",
            "rule_content_list":[
                {
                    "value":"分層1",
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "type":"profile_rule",
                                    "field":"user.$first_visit_time",
                                    "function":"equal",
                                    "params":[
                                        "2019-12-10 00:00:00:00"
                                    ]
                                }
                            ]
                        },
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "measure":{
                                        "aggregator":"general",
                                        "field":"",
                                        "type":"event_measure",
                                        "event_name":"buy"
                                    },
                                    "type":"event_rule",
                                    "time_function":"relative_time",
                                    "time_params":[
                                        "1 day"
                                    ],
                                    "params":[
                                        1
                                    ],
                                    "function":"least",
                                    "filters":[
    
                                    ]
                                }
                            ]
                        },
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "type":"event_sequence_rule",
                                    "time_function":"relative_time",
                                    "time_params":[
                                        "1 day"
                                    ],
                                    "steps":[
                                        {
                                            "event":"buy",
                                            "filters":[
    
                                            ]
                                        },
                                        {
                                            "event":"buy",
                                            "filters":[
    
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "base_time":"2019-12-18 00:00:00",
            "start_time":"2019-12-18 01:00:26",
            "finished_time":"2019-12-18 01:00:30",
            "user_count":0,
            "status":"SUCCEED",
            "rule_content_list":[
                {
                    "value":"分層1",
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "type":"profile_rule",
                                    "field":"user.$first_visit_time",
                                    "function":"equal",
                                    "params":[
                                        "2019-12-10 00:00:00:00"
                                    ]
                                }
                            ]
                        },
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "measure":{
                                        "aggregator":"general",
                                        "field":"",
                                        "type":"event_measure",
                                        "event_name":"buy"
                                    },
                                    "type":"event_rule",
                                    "time_function":"relative_time",
                                    "time_params":[
                                        "1 day"
                                    ],
                                    "params":[
                                        1
                                    ],
                                    "function":"least",
                                    "filters":[
    
                                    ]
                                }
                            ]
                        },
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "type":"event_sequence_rule",
                                    "time_function":"relative_time",
                                    "time_params":[
                                        "1 day"
                                    ],
                                    "steps":[
                                        {
                                            "event":"buy",
                                            "filters":[
    
                                            ]
                                        },
                                        {
                                            "event":"buy",
                                            "filters":[
    
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]

    新增指定時間區間內的所有partition

    [PUT ​/v2/user_tags​/{id}/partitions​]

    參數名

    是否必填

    類型

    描述

    from_date

    String

    設定時間範圍,開始時間(含)
    格式:2018-05-04 04:00:00 或者 2018-05-04 均可
    from_data 不能晚於 to_date

    to_date

    String

    設定時間範圍,結束時間(含)
    格式:2018-05-06 04:00:00 或者 2018-05-06 均可
    參數不能晚於今天

  • Response 200

    /v2​/user_tags​/{id}/partitions?from_date=2019-12-16&to_date=2019-12-18

    檢查標籤執行狀態

    [GET ​/v2/user_tags​/{id}/status​]

    • Request
    /v2/user_tags/{id}/status?base_time_list=2019-12-16%2000:00:00
    • Response 200 (application/json)
    [
      {
        "base_time": "2019-12-16 00:00:00",
        "user_count": 0,
        "status": "SUCCEED",
        "start_time": "2019-12-16 01:01:02",
        "finished_time": "2019-12-16 01:01:02"
      }
    ]

    執行一個分頁的指定 partition

  • [PATCH /v2​/user_tags​/{id}/execute​]

    • Request 
    /v2/user_tags/{id}/execute?base_time_list=2019-12-13%2000:00:00
  • 獲取標籤完整的目錄結構

    [GET ​/v2/user_tags​/dirs​]

    • Request 
    /v2/user_tags/dirs?need_user_tag=false
  • 參數名

    是否必填

    類型

    描述

    need_user_tag

    String

    目錄結構內預設包含目錄下的所有標籤資訊,設為 false 則只返回目錄結構. 只在取得目錄結構時使用

    tag_status

    String

    標籤狀態,PENDING待審批,RUNNING 正常運行,SUSPEND 已暫停

    unit

    String

    標籤更新週期, 取值範圍: DAY 每日更新

    source_type

    Integer

    標籤類型, 取值範圍:1 rule 篩選規則,2 query_result 查詢結果,5 upload 上傳創建,6 import 外部導入,7 SQL sql創建(不使用 0,3,4是為了避免升級操作,用 6 是因為 1.13 的 6 沒有用到)

    last_partition_status

    String

    狀態,新建標籤還未執行:NEW、執行中:COMPUTING、執行成功:SUCCEED、執行失敗:FAILED

    is_routine

    Integer

    是否例行標籤或使用者群 1是 0否

  • Response 200 (application/json)

    [
      {
        "type": "DIR",
        "id": 1,
        "cname": "未分類",
        "is_default": true,
        "items": [
          {
            "type": "USER_TAG",
            "id": 12,
            "name": "user_tag_biaoqian3",
            "cname": "標籤3",
            "data_type": "STRING",
            "is_permitted": false
          },
          {
            "type": "USER_TAG",
            "id": 13,
            "name": "user_tag_biaoqian4",
            "cname": "標籤4",
            "data_type": "STRING",
            "is_permitted": false
          }
        ]
      },
      {
        "type": "DIR",
        "id": 8,
        "cname": "目錄1",
        "items": [
          {
            "type": "USER_TAG",
            "id": 2,
            "name": "user_tag_xxx1_1",
            "cname": "xxx1_1",
            "data_type": "STRING",
            "is_permitted": true
          },
        ]
      },
      {
        "type": "DIR",
        "id": 9,
        "cname": "目錄2",
        "items": [
          {
            "type": "USER_TAG",
            "id": 4,
            "name": "user_tag_xxx2_2",
            "cname": "xxx2_2",
            "data_type": "STRING",
            "is_permitted": false
          }
        ]
      }
    ]

    獲取標籤清單

    [GET ​/v2/user_tags​​]

  • Request (application/json)

    /v2/user_tags?invisible=false

    參數名

    是否必填

    類型

    描述

    start

    Integer

    從第幾個開始取數據

    count

    Integer

    取多少個

    invisible

    Boolean

    是否展示隱藏目錄的標籤(目前是是否顯示使用者畫像的標籤 false 為不顯示)

  • Response 200 (application/json)

    [
        {
            "id":2,
            "dir_id":8,
            "name":"user_tag_xionghuacheng1_1",
            "cname":"xionghuacheng1_1",
            "user_name":"xionghuacheng1@qq.com",
            "create_time":"2019-11-27 12:02:24",
            "data_type":"STRING",
            "unit":"DAY",
            "source_type":1,
            "is_routine":true,
            "status":"RUNNING",
            "comment":"",
            "cron":"0 0 0 * * ? *",
            "rule_content_list":[
                {
                    "value":"分層1",
                    "type":"rules_relation",
                    "relation":"and",
                    "rules":[
                        {
                            "type":"rules_relation",
                            "relation":"and",
                            "rules":[
                                {
                                    "measure":{
                                        "aggregator":"general",
                                        "field":"",
                                        "type":"event_measure",
                                        "event_name":"buy"
                                    },
                                    "type":"event_rule",
                                    "time_function":"relative_time",
                                    "time_params":[
                                        "1 day"
                                    ],
                                    "params":[
                                        1
                                    ],
                                    "function":"least",
                                    "filters":[
    
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ],
            "failed_partition_count":0,
            "last_succeed_partition":{
                "base_time":"2019-12-18 00:00:00",
                "start_time":"2019-12-18 01:00:59",
                "finished_time":"2019-12-18 01:01:02",
                "user_count":0,
                "status":"SUCCEED",
                "rule_content_list":[
                    {
                        "value":"分層1",
                        "type":"rules_relation",
                        "relation":"and",
                        "rules":[
                            {
                                "type":"rules_relation",
                                "relation":"and",
                                "rules":[
                                    {
                                        "measure":{
                                            "aggregator":"general",
                                            "field":"",
                                            "type":"event_measure",
                                            "event_name":"buy"
                                        },
                                        "type":"event_rule",
                                        "time_function":"relative_time",
                                        "time_params":[
                                            "1 day"
                                        ],
                                        "params":[
                                            1
                                        ],
                                        "function":"least",
                                        "filters":[
    
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            "last_partition_info":{
                "base_time":"2019-12-18 00:00:00",
                "start_time":"2019-12-18 01:00:59",
                "finished_time":"2019-12-18 01:01:02",
                "user_count":0,
                "status":"SUCCEED",
                "next_partition_base_time":"2019-12-19 00:00:00"
            }
        }
    ]

    匯出標籤使用者

    [POST ​​/v2/reports​/user_analytics​/users​] 注意:該介面不支援高併發查詢

  • Request (application/json)

    {
        "filter":{// 單層篩選條件
            "conditions":[
                {
                    "field":"user.user_tag_tag24@2019-12-18 00:00:00",// 具體屬性
                    "function":"isSet"// 條件函數
                }
            ]
        },
        "from":"user_tags",
        "num_per_page":50,
        "page":0,// 第幾頁
        "all_page":false,// 是否顯示所有頁數
        "profiles":[// 需要顯示的列,用户屬性列表
            "user.viplevel",
            "user.$device_id_list",
            "user.$name",
            "user.city",
            "user.province",
            "user.user_group_fenqun24"
        ],
        "limit":1000,// 列表總數
        "request_id":"1576665438553:312117",
        "use_cache":false
    }
  • Response 200 (application/json)

    {
        "page_num":1,// 頁數
        "size":2,//總人數
        "column_name":[// 用户屬性列表
            "viplevel",
            "$device_id_list",
            "$name",
            "city",
            "province",
            "behaviorGender"
        ],
        "permitted_properties":[// 用户屬性權限,有權限的屬性名
            "viplevel",
            "$device_id_list",
            "$name",
            "city",
            "province",
            "behaviorGender"
        ],
        "users":[// 用户列表
            {
                "id":"-8730216594566797645",
                "first_id":"00023177fb8b1c65",
                "profiles":{
                    "$name":"吴掭歂",
                    "province":"上海",
                    "city":"石家庄",
                    "behaviorGender":"男",
                    "viplevel":"青铜"
                }
            },
            {
                "id":"-8832516550883297125",
                "first_id":"00144ec2ba6496ec",
                "profiles":{
                    "$name":"姜俿搝",
                    "province":"北京",
                    "city":"上海",
                    "behaviorGender":"女",
                    "viplevel":"白银"
                }
            }
        ]
    }

    匯出csv格式標籤使用者

    [POST ​​/v2/reports​/user_analytics​/users​/csv​] 注意:該介面不支援高同步查詢

  • Request (application/json)

    {
        "filter":{
            "conditions":[
                {
                    "field":"user.user_group_fenqun24@2019-12-18 00:00:00",
                    "function":"isSet"
                }
            ]
        },
        "all_page":true
    }
  • Response 200

    下載csv格式的檔案

    查詢使用者標籤值資訊

    [POST ​​/v2/persona_info/user_tags​] 注意:該介面不支援高併發查詢,建議一次查詢最多查詢20個標籤值

  • Request (application/json)


    {
    	"user_id":"-5568802382350089752", // 神策ID
    	"user_tag_ids":[10,11,21,25,17,19,7,13,18] //待查詢標籤IDs
    }
  • Response 200


{
  "user_tags": [
    {
      "tag_id": 21,
      "cname": "用户生命周期",
      "value": "新用户",
      "data_type": 2,
      "partition_info": {
        "base_time": "2020-03-23 00:00:00",
        "start_time": "2020-03-25 10:26:44",
        "finished_time": "2020-03-25 10:27:11",
        "user_count": 26829,
        "status": "SUCCEED"
      }
    },
    {
      "tag_id": 19,
      "cname": "收藏頻次",
      "value": "3",
      "data_type": 1,
      "partition_info": {
        "base_time": "2020-03-27 00:00:00",
        "start_time": "2020-03-27 01:01:30",
        "finished_time": "2020-03-27 01:01:54",
        "user_count": 19685,
        "status": "SUCCEED"
      }
    },
    ...... 
		// 1、該介面會透過權限過濾,傳回使用者擁有權限的標籤資料
		// 2、該介面只會傳回使用者擁有標籤值的標籤項目
  ]
}