API call to create an audience segmentation rule.
The user must be authenticated and have write permissions to the siteGroup.
Within the last 31 days segments can be formed from any traffic filter. For periods older than the last 31 days, segments can be formed only when the following conditions are met:
-
All sites in the site group are configured for long term storage (LTS) with a period equal to or exceeding the segment period.
-
Explode users / user having filters can only be used for single-site groups.
Request
The request object has the following fields:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
String |
Yes |
The site group identifier to store the segmentation rule under. |
|
|
String |
Yes |
Segment name. Maximum 250 characters. |
|
|
String |
No |
Segment description. Maximum 250 characters. |
|
|
String |
Defaults to |
The type of the segment, and must be either /segment/data/update . A |
|
|
Array of Object |
For type |
A list of filters that define a subset of the audience. The filter syntax is documented here . Note that the segment should include a time-filter to specify the length of time of event traffic to use as basis for the segment. If not, the time period the segment covers is 24 hours. The maximum time period is 31 days, unless the sites are configured for long term storage (LTS) (see the warning above). |
|
|
Array of Object |
No |
A list of key/value pairs that can be used to look up the segment (see /segment/read ). |
|
|
boolean |
No |
Set to True to enable the segment for active usage. Explained here . |
|
|
boolean |
No |
Set to True to make the segment internal to protect from nonadmin altering. |
|
|
String |
No |
Name of the segment group to assign this segment to |
|
|
Number |
No |
The expiration date which shows when the current segment can be automatically deleted. |
|
|
boolean |
No |
Include users without events in export. |
Response
The response object for a successful query has the following fields:
|
Name |
Type |
Description |
|---|---|---|
|
|
String |
The identifier for the audience segment |
|
|
String |
The site group identifier to which this audience segment belongs |
|
|
String |
The name of this audience segment |
|
|
String |
A description for this audience segment |
|
|
String |
The type of the segment, either |
|
|
Array of object |
Array of filters that defines the segment. The filter syntax is documented here . |
|
|
Array of object |
Key/value pairs that can be used to look up the segment |
|
|
boolean |
True if segment is enabled for active usage. Explained here . |
|
|
String |
Assigned group name |
|
|
Array of String |
Widget IDs if segment is used in CCE. |
|
|
Number |
Pre-evaluated cost of the segment by the platform. Please note that for certain segments the cost can be unevaluated and hence unavailable, in which case in order to evaluate the cost, the /segment/validate API must be used instead. |
|
|
String |
The expiration date which shows when the current segment can be automatically deleted. |
|
|
String |
True if the segment is compatible with contextual targeting. |
|
|
Array of String |
Segment IDs of all the segments that reference current segment either directly or through other segments. |
|
|
Array of String |
Segment IDs of all the segments that reference current segment directly. |
|
|
boolean |
Include users without events in export. |
Examples
$ python cx.py /segment/create '{"siteGroupId":"10501", "name":"Google-referrer", "description":"Events with google as referrer", "filters":[{"type":"time", "start":"-2d", "filter":{"type":"event", "group":"referrerHost", "item":"google.com"}}]}'
{
"id": "8kwfp77cuw474p",
"siteGroupId": "10501",
"name": "Google-referrer",
"description": "Events with google as referrer",
"filters": [
{
"type": "time",
"start":"-2d",
"filters": [
{
"type": "event",
"group": "referrerHost",
"item": "google.com"
}
]
}
]
}
$ python cx.py /segment/create '{"siteGroupId":"10501", "name":"DMP", "description":"User Dmp Events", "type":"dmp", filters":[{"type":"user","having":{"min":1,"filter":{"type":"dmp-event","group":"origin","item":"user-filtering"}}}]}'
{
"id": "8kwfp77cuw474l",
"siteGroupId": "10501",
"name": "DMP",
"description": "User Dmp Events",
"filters": [
{
"type": "user",
"having": {
"min": 1,
"filter": {
"type": "dmp-event",
"group": "origin",
"item":"user-filtering"
}
}
}
]
}
$ python cx.py /segment/create '{"siteGroupId":"9222693460714263881","name":"Combined Segment","description":"Test description","type":"combined","filters":[{"type":"composition","tree":{"or":[{"segmentId":"1y2ibz9icng3w"},{"segmentId":"1y2ibz9icng3x"}]}}]}'
{
"id": "1y2ibz9icng3y",
"siteGroupId": "9222693460714263881",
"name": "Combined Segment",
"description": "Test description",
"filters": [
{
"type": "composition",
"tree": {
"or": [
{
"segmentId": "1y2ibz9icng3w"
},
{
"segmentId": "1y2ibz9icng3x"
}
]
}
}
]
}