Read your Vercel Web Analytics from the terminal
The Vercel dashboard shows Web Analytics for one project at a time. I wanted the numbers in a terminal and in scripts. So I made vercel-analytics-api , a small client for Vercel's public API (MIT, unofficial, no dependencies). Terminal The command uses your Vercel CLI login and current team: npx vercel-analytics-api visitors --since 30d PROJECT VISITORS PAGE VIEWS example.com 1,200 3,400…
Vercel's Web Analytics are typically viewed through their dashboard, one project at a time. However, a user wanted to access these metrics in a terminal and through scripts. To fulfill this need, they created vercel-analytics-api, an unofficial client for Vercel's public API.
This simple API client allows users to interact with Vercel's analytics data using their Vercel CLI login and current team. The command 'npx vercel-analytics-api visitors --since 30d PROJECT VISITORS PAGE VIEWS' can be used to display visitors for a specific project. For instance, example.com had 1,200 visitors while docs.example.com had 480.
If you want to see the top 5 pages for a project, you can use 'npx vercel-analytics-api top pages -p example.com -n 5'. For more detailed data in JSON format, 'npx vercel-analytics-api series -p example.com --json' is the command to use.
The client is capable of reading additional data such as referrers, countries, custom events, and Core Web Vitals. It also offers recipes for generating a weekly Slack report in GitHub Actions and a CSV export.
Remember, visitors are unique to each window and a week's worth of visitors is less than the sum of visitors each day. The API does not provide bounce rates, and UTMs can only be broken down with Vercel Plus. The vercel-analytics-api was developed while creating Lookout, a dashboard for monitoring all Vercel projects; this package does not require Lookout to function.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.