Get ranked traffic breakdown
umami_get_metricsBreak down traffic by pages, referrers, countries, devices, channels, and more to surface top performers. Enable expanded mode to get engagement metrics like bounce rate and visit duration per row.
Instructions
Get a ranked breakdown of traffic by one dimension: top pages, referrers, countries, browsers, devices, acquisition channels, custom events, and more.
This is the workhorse for "top N" questions. Set expanded=true when you need engagement quality per row (pageviews, visitors, visits, bounces, time on site) rather than just a visitor count, for example to find which landing page bounces hardest.
Args:
website (string, optional): Website ID, name, or domain.
type (string, required): Dimension to break down by. 'path' (pages), 'entry' (landing pages), 'exit', 'referrer', 'channel', 'domain', 'country', 'region', 'city', 'browser', 'os', 'device', 'language', 'screen', 'title', 'query', 'event', 'hostname', 'tag', 'distinctId'.
range (string): Date range, default '7d'.
start_date / end_date (string, optional): Explicit bounds, overriding 'range'.
expanded (boolean): Return per-row engagement metrics instead of a single count (default: false).
limit (number): Rows to return, 1-500 (default: 20).
offset (number): Rows to skip for pagination (default: 0).
filters (object, optional): Segment filters, for example { country: 'US' } to see top pages among US visitors.
response_format ('markdown' | 'json'): Output format (default: 'markdown').
Returns: Plain JSON shape: { "type": string, "count": number, "rows": [ { "name": string, "visitors": number, "share_pct": number } ], "has_more": boolean, "next_offset": number } Expanded JSON shape: { "type": string, "count": number, "rows": [ { "name": string, "pageviews": number, "visitors": number, "visits": number, "bounces": number, "bounce_rate_pct": number, "avg_visit_duration_seconds": number } ], ... }
Examples:
"What are our top 10 pages this month?" -> type="path", range="this_month", limit=10
"Where is traffic coming from?" -> type="referrer", range="30d"
"Which landing page has the worst bounce rate?" -> type="entry", expanded=true
"Top pages for mobile visitors in Florida" -> type="path", filters={ device: "mobile", region: "US-FL" }
Error handling:
Returns "No data" when the dimension has no rows in the range, which is expected for 'event' when no custom events are tracked.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | What to break traffic down by. 'path' for pages, 'referrer' for referring URLs, 'channel' for acquisition channel, 'entry'/'exit' for landing and exit pages, 'event' for custom events, plus country, region, city, browser, os, device, language, screen, title, query, domain, hostname, tag, distinctId. | |
| limit | No | Maximum rows to return. | |
| range | No | Date range for the query, default '7d'. Relative ("30m", "24h", "7d", "4w", "3mo", "1y"), named ("today", "yesterday", "this_week", "last_week", "this_month", "last_month", "this_year", "last_year", "mtd", "ytd", "all_time"), or an explicit ISO date via start_date/end_date. | |
| offset | No | Rows to skip, for pagination. | |
| filters | No | Optional segment filters. Supported keys: path, referrer, title, query, browser, os, device, country, region, city, language, hostname, tag, event, distinctId, utmSource, utmMedium, utmCampaign, utmContent, utmTerm, segment, cohort. Example: { country: 'US', device: 'mobile' }. | |
| website | No | Website ID (UUID), name, or domain. Optional if UMAMI_DEFAULT_WEBSITE is set. Use umami_list_websites to discover values. | |
| end_date | No | Explicit end date (YYYY-MM-DD, ISO 8601 timestamp, or epoch ms). Overrides 'range'. | |
| expanded | No | Return per-row engagement metrics (pageviews, visits, bounces, time) instead of a single count. | |
| start_date | No | Explicit start date (YYYY-MM-DD, ISO 8601 timestamp, or epoch ms). Overrides 'range'. | |
| response_format | No | Output format: 'markdown' for a readable summary, 'json' for raw structured data. | markdown |