# CDP Backend - Segmentation API request format (20231012 edit) ## Audience (post) /audience/segment ``` { "id": 1, // 每跑一次task 會生成新的 id "segmentId": 7, // 人群id "brandId(new)": 1, "logic": "AND", "interval": 90, "maxCount": 1000, "tagGroups": [ { "include": { "logic": "AND", "tags": [ { "id": 2, "tagType": 1, "rule": { "logic": "AND( join rule between each criteria below)", "criteria": [ { "siteId": "1a70edf", "dataSourceId(new)": 11, "mappingKeys(new)": [ // query 中用來跟mapping table 的join key { "col": "ckid", // data source 的欄位名稱 "key": "global_ckid", // "isPII": true }, { "col": "cid", "key": "globla_cid", "isPII": false } ], "category": "VISIT", "period": 71, "indic": { "col": "vTimes", "func": "SUM", "val": "5" }, "filters": [ { "col": "geoId", "operator": "Equal", "val": "1158000000", "isTotal": false }, { "col": "isNew", "operator": "Equal", "val": 1, "isTotal": false } ] } ] } }, { "id": 1, "tagType": 2, "rule": { "logic": "AND", "criteria": [ { "campId": "80497", "dataSourceId": 13, "mappingKeys(new)": [ { "col": "ckid", "key": "global_ckid", "isPII": true } ], "category": "impression", "period": 60, "filters": [ { "col": "click", "operator": "Gt", "val": 30, "isTotal": true }, { "col": "country", "operator": "Equal", "val": 1158, "isTotal": false } ] } ] } }, { "id": 1, "tagType": 5, //location "location": { "code":visitor, "points" :[ { "id":46, "lat":25.08027395138645, "lon":121.23576164245608, "distance": 633 }, { "id": 47, "lat":25.08027395138645, "lon":121.23576164245608, "distance": 633 } ] } }, { "tagType": 7, // interest "clientTagId": "tagid1=" // ex: 77 }, { "tagType": 7, // interest "clientTagId": "tagid2=" // ex: 78 }, { "tagType": 8, // APP "clientTagId" : 1 }, { "tagType": 8, // APP "clientTagId" : 2 }, { "tagType" : 9 //taxonomy "taxonomy": [11, 12, 13] } ] }, "exclude": { "logic": "OR", "tags": [] } }, { "exclude": { "logic": "AND", "tags": [ ] }, "include": { "logic": "PROFILE", "tags": [ { "clientTagId": "age_A", "id": "age_A", "tagType": 6 }, { "tagType": 6, // profile 人群屬性 "clientTagId": "age_A" }, { "tagType": 6, "clientTagId": "homeCity_1" }, { "tagType": 6, "clientTagId": "gender_1" }, { "tagType": 6, "clientTagId": "workCity_1" } ] } } ] } ``` Notes: - tagType → site/ track/ ... ## Criteria ### data source:site ``` { "logic" : "AND", "criteria" : [ { "sitdId" : "2eedef", "dataSourceId": 11, "category" : "EVENT", "period" : 60, "filters": [ { "col": "device", "operation" : "Equal", "val" : "iphone", "isTotal" : false }, { "col" : "click", "operation" : "Gt", "val" : "10", "isTotal":true } ] } ] } ``` ### data source:track ``` { "logic" : "AND", "criteria" : [ { "campId": "80497", "dataSourceId": 13, "category": "impression", "period": 60, "filters" :[ { "col": "click", "operator": "Gt", "val": 3, "isTotal": true, }, { "col": "country", "operator": "Equal", "val": "1158", "isTotal": false } ] } ] } ``` ### using aggregation function(聚合函數) ``` { "logic": "AND", "criteria": [ { "siteId": "1a70edf", "dataSourceId": 11, "category": "VISIT", "period": 71, "indic": { "col": "vTimes", "func": "SUM", "val": "5" }, "filters": [ { "col": "geoId", "operator": "Equal", "val": "1158000000", "isTotal" : false }, { "col": "isNew", "operator": "Equal", "val": 1, "isTotal" : false } ] } ] }, } ```