Accessing Metrics with Vercel CLI
Use vercel metrics to query Web Analytics data from your terminal. You can reproduce common dashboard views, then go further with custom filters, multiple groupings, custom event analysis, UTM dimensions, and team-wide queries.
Web Analytics metrics are available through vercel metrics without Observability Plus.
The schema is the source of truth for the metrics, dimensions, and aggregations available to your account. Start by inspecting the available Web Analytics metrics:
vercel metrics schema
vercel metrics schema vercel.analyticsUse these examples to query the same kinds of traffic views available in the Web Analytics dashboard.
Query daily page views for the last seven days:
vercel metrics vercel.analytics.page_view.count --since 7d --granularity 1d --project project-name --prodSee the top countries by page views:
vercel metrics vercel.analytics.page_view.count --group-by country --since 7d --limit 10 --project project-name --prodQuery unique visitors from a specific country over the last day:
vercel metrics vercel.analytics.page_view.count --aggregation unique/visitorId --filter 'country:US' --since 1d --granularity 1h --project project-name --prodList the most common custom event names:
vercel metrics vercel.analytics.event.count --group-by eventName --since 7d --limit 20 --project project-name --prodThe following query shapes are not available in the Web Analytics dashboard. Use them when you need more precise filtering, multi-dimensional comparisons, custom event analysis, or team-wide reporting.
Use a field-scoped OR expression to include multiple path prefixes, != to exclude a value, and repeated --group-by options to compare the remaining traffic by path and device type:
vercel metrics vercel.analytics.page_view.count --filter 'requestPath:(/docs* OR /guides*)' --filter 'country != US' --group-by requestPath --group-by deviceType --since 7d --project project-name --prodFilter by a custom event name, then group results by country and device type:
vercel metrics vercel.analytics.event.count --filter 'eventName:signup' --group-by country --group-by deviceType --since 7d --project project-name --prodGroup page views by UTM source and campaign to compare campaign traffic:
vercel metrics vercel.analytics.page_view.count --group-by utmSource --group-by utmCampaign --since 7d --project project-name --prodUse --all with projectId to compare production traffic across every project in the current team:
vercel metrics vercel.analytics.page_view.count --all --group-by projectId --group-by country --since 7d --limit 20 --prodFor all options, see the vercel metrics reference.
Was this helpful?