Skip to main content

Segment

Overview​

The segment parameter allows you to define behavioral segments for your analysis. Segments can filter your data based on specific user behaviors and characteristics across different scopes.

Parameters​

Main Parameters​

ParameterDescriptionValuesRequired
scopeDefines the segmentation typevisit_id, user_id, visitor_id, event_id, av_session_id, cart_id, pageview_idYes
segmentKeyReference to a saved segmentStringNo
contentSegment definition (see below)ObjectYes (if no segmentKey)
modeInclude or exclude the behaviorinclude, excludeYes
periodTime period for the behavior (visitor/user segments)See Period documentationNo
spaceSites where behavior occurred (visitor/user segments)See Sites documentationNo

Content Parameters​

ParameterDescriptionValuesRequired
conditionContains the filter for the segmentObjectYes
filterDescribes the behavior to trackSee Filter documentationYes

Scope Types​

Find detailed information about different segmentation scopes in the help center.

Examples​

Example 1: Simple device type segment​

Segment visitors using desktop devices.

{
"segment": {
"section": {
"scope": "visit_id",
"content": {
"condition": {
"filter": {
"device_type": {
"$eq": "Desktop"
}
}
}
},
"mode": "include"
}
}
}

Example 2: Visitor segment with time period​

Segment visitors from France in the previous month.

{
"segment": {
"section": {
"scope": "visitor_id",
"mode": "include",
"period": {
"p1": [
{
"type": "R",
"granularity": "M",
"startOffset": -1,
"endOffset": -1
}
]
},
"content": {
"condition": {
"filter": {
"visit_geo_country": {
"$eq": "France"
}
}
}
}
}
}
}

Example 3: Using saved segment​

Reference a previously saved segment.

{
"segment": {
"section": {
"segmentKey": "mobile_users_france",
"mode": "include"
}
}
}