curl --request GET \
--url https://api.example.com/api/websites/:id/metrics{
"data": {
"type": "<string>",
"rows": [
{
"value": "<string>",
"visitors": 123,
"pageviews": 123,
"bounce_rate": 123,
"avg_duration_seconds": 123,
"prev_visitors": 123,
"prev_pageviews": 123,
"delta_visitors_abs": 123,
"delta_visitors_pct": 123
}
]
},
"pagination": {
"total": 123,
"limit": 123,
"offset": 123,
"has_more": true
},
"compare": {
"mode": "<string>",
"primary_range": [
{}
],
"comparison_range": [
{}
]
}
}Retrieve a breakdown of analytics data by dimension (pages, referrers, countries, browsers, etc.) with ranking and comparison support.
curl --request GET \
--url https://api.example.com/api/websites/:id/metrics{
"data": {
"type": "<string>",
"rows": [
{
"value": "<string>",
"visitors": 123,
"pageviews": 123,
"bounce_rate": 123,
"avg_duration_seconds": 123,
"prev_visitors": 123,
"prev_pageviews": 123,
"delta_visitors_abs": 123,
"delta_visitors_pct": 123
}
]
},
"pagination": {
"total": 123,
"limit": 123,
"offset": 123,
"has_more": true
},
"compare": {
"mode": "<string>",
"primary_range": [
{}
],
"comparison_range": [
{}
]
}
}page - Top pages by trafficreferrer - Top referrer domainscountry - Traffic by countryregion - Traffic by region/statecity - Traffic by citybrowser - Browser breakdownos - Operating system breakdowndevice - Device type breakdownlanguage - Browser language breakdownutm_source - UTM source parameterutm_medium - UTM medium parameterutm_campaign - UTM campaign parameterhostname - Hostname breakdownYYYY-MM-DD format. Defaults to 6 days ago if not provided.YYYY-MM-DD format. Defaults to today if not provided.America/New_York). Defaults to UTC.none, previous_period, previous_year, or custom.compare_mode=custom).compare_mode=custom).compare_mode is set).compare_mode is set).compare_mode is set).compare_mode is set).curl -X GET "https://analytics.example.com/api/websites/abc123/metrics?type=page&limit=10&start_date=2024-03-01&end_date=2024-03-07" \
-H "Authorization: Bearer spk_live_your_api_key"
{
"data": {
"type": "page",
"rows": [
{
"value": "/",
"visitors": 2341,
"pageviews": 3892,
"bounce_rate": 38.2,
"avg_duration_seconds": 145.3
},
{
"value": "/pricing",
"visitors": 1823,
"pageviews": 2104,
"bounce_rate": 42.1,
"avg_duration_seconds": 98.7
},
{
"value": "/features",
"visitors": 1542,
"pageviews": 1876,
"bounce_rate": 35.6,
"avg_duration_seconds": 132.4
},
{
"value": "/docs",
"visitors": 1203,
"pageviews": 4521,
"bounce_rate": 28.9,
"avg_duration_seconds": 287.1
},
{
"value": "/blog/getting-started",
"visitors": 891,
"pageviews": 1012,
"bounce_rate": 51.3,
"avg_duration_seconds": 76.5
}
]
},
"pagination": {
"total": 124,
"limit": 10,
"offset": 0,
"has_more": true
},
"compare": null
}
curl -X GET "https://analytics.example.com/api/websites/abc123/metrics?type=country&limit=5&start_date=2024-03-01&end_date=2024-03-07&compare_mode=previous_period" \
-H "Authorization: Bearer spk_live_your_api_key"
{
"data": {
"type": "country",
"rows": [
{
"value": "US",
"visitors": 1823,
"pageviews": 4521,
"bounce_rate": 41.2,
"avg_duration_seconds": 125.3,
"prev_visitors": 1542,
"prev_pageviews": 3891,
"delta_visitors_abs": 281,
"delta_visitors_pct": 18.2
},
{
"value": "GB",
"visitors": 891,
"pageviews": 2103,
"bounce_rate": 38.7,
"avg_duration_seconds": 142.1,
"prev_visitors": 923,
"prev_pageviews": 2234,
"delta_visitors_abs": -32,
"delta_visitors_pct": -3.5
},
{
"value": "DE",
"visitors": 723,
"pageviews": 1654,
"bounce_rate": 43.1,
"avg_duration_seconds": 108.9,
"prev_visitors": 651,
"prev_pageviews": 1502,
"delta_visitors_abs": 72,
"delta_visitors_pct": 11.1
}
]
},
"pagination": {
"total": 47,
"limit": 5,
"offset": 0,
"has_more": true
},
"compare": {
"mode": "previous_period",
"primary_range": ["2024-03-01", "2024-03-07"],
"comparison_range": ["2024-02-23", "2024-02-29"]
}
}
VALID_METRIC_TYPES constant in the backendlimit parameter is clamped to 1-100offset for pagination to retrieve additional resultsprev_*, delta_*) are only included when compare_mode is set