This feature allows you to deeply segment your website pages into several sections such as page type, in which we could define article pages, navigation pages, user pages, etc.
The segments can be configured in your project settings.
Segment feature’s fields.
The segments feature provides 4 main fields:
Note: X
is the segment number as defined in your project configuration (refers to Get Metadata)
Note: depth_X
fields are meant to be used to aggregate on the first, second and third depth of their value.
If pagetype
is your first segment, an URL with a pagetype books/food
would have the following field values:
books/food
(full value)books
food
null
(no depth 3)The following examples use URLs aggregation to compute metrics on segments.
In the following example, we assume that the first segment is pagetype.
{
"aggs": [
{
"group_by": [
"segments.segment_1.value"
]
}
]
}
{
"aggs": [
{
"group_by": [
"segments.segment_1.depth_1",
],
"metrics": [
{
"sum": "visits.organic.all.nb"
}
]
}
]
}
{
"aggs": [
{
"group_by": [
"segments.segment_1.depth_1",
{
"range": {
"field": "search_engines.google.crawls.count",
"ranges": [
{ "from": 1 }, // Crawled
{ "from": 0, "to": 1 } // Not Crawled
]
}
}
]
}
]
}
Segments feature metadata includes:
- list of configured segments (limited to two).
- segment config
analyses/{username}/{project_slug}/{analysis_slug}
Analysis
curl "https://api.botify.com/v1/analyses/${username}/${project_slug}/${analysis_slug}" \
-X GET \
-H "Authorization: Token ${API_KEY}" \
-H "Content-type: application/json"
You can find the list of the segment names at features.segments.names
and the config in features.segments.rules_raw
.
Note: If feature is not enabled, features.segments
resolves to null
.
An extract of the response could be the following.
{
"features": {
"segments": {
"rules_raw": "[dim:pagetype]\n\n@articles\n\n[dim:lang]\n\n@us",
"names": ["pagetype", "lang"]
},
...
},
...
}