Web Analytics for Developers: API-First, Privacy-First
Developers don't want dashboards they have to click through. They want APIs they can query, scripts that don't slow down their sites, and analytics that respect user privacy without consent banners. Here's how to get there.
At a Glance
- Developers need analytics tools with REST APIs, not just dashboards — so they can pipe data into CI/CD, Slack, or custom reporting.
- The best developer analytics scripts are under 5 KB, cookie-free, and installable via npm or a single script tag.
- This guide covers four API-first tools: Copper Analytics, Plausible, Umami, and PostHog.
- Headless analytics — consuming data purely through APIs without ever opening a dashboard — is a growing pattern among engineering teams.
- Copper Analytics offers a free tier with a full REST API, AI crawler tracking, and data export capabilities.
Jump to section
What Developers Actually Want from Analytics
Most analytics tools were built for marketers. They assume you want funnels, heatmaps, session recordings, and A/B testing dashboards. For developers, the requirements are fundamentally different. You want data you can programmatically access, scripts that don't degrade page performance, and privacy guarantees that mean you never have to think about consent banners.
After surveying hundreds of developer-focused teams, the same requirements come up again and again:
- A well-documented REST API: The ability to query pageviews, referrers, top pages, and custom events programmatically. If you can't
curlit, it doesn't exist. - A lightweight tracking script: Under 5 KB, ideally under 1 KB. No blocking the main thread, no layout shifts, no third-party cookie jars.
- No cookies: Cookie-free analytics means no consent banners, no GDPR pop-ups, and no legal review before deploying a script tag.
- Self-hosting option: Many teams want analytics running on their own infrastructure, behind their own firewall, with full data ownership.
- npm or script-tag install: Two lines of code to get started. No vendor onboarding calls, no sales demos, no “schedule a meeting” CTAs.
- Data export: CSV, JSON, or API-based export so you can pipe analytics into your own data warehouse, Grafana, or Jupyter notebooks.
The tools that meet these criteria are a small subset of the analytics market. Let's walk through the four best options for developer teams.
Copper Analytics: Built for Developers from Day One
Copper Analytics was designed with developer ergonomics as a first-class concern. The tracking script is a single async tag, the REST API covers every metric visible in the dashboard, and the entire platform works without cookies or personal data collection.
Key Features for Developers
- Full REST API: Query pageviews, visitors, referrers, top pages, devices, browsers, and countries. Filter by date range, path, or referrer domain.
- AI crawler tracking: See which bots (GPTBot, ClaudeBot, Perplexity, Bytespider) are crawling your site, how frequently, and which pages they target.
- Core Web Vitals: LCP, CLS, INP, FCP, and TTFB are tracked automatically — no separate performance monitoring tool needed.
- Data export: Export any time range as CSV or JSON via the API. Connect to your own data pipelines. See the data export feature page for details.
- Lightweight script: Under 4 KB, async-loaded, no cookies, no personal data, no layout shift.
- Free tier: Not a trial — a permanent free plan for smaller sites and side projects.
Developer Tip
Copper Analytics's API uses standard Bearer token authentication. Generate an API key from your dashboard settings and start querying within minutes. No OAuth flows, no webhook registration — just a token and a GET request.
Plausible Analytics: Open Source with a Stats API
Plausible is the go-to open-source privacy analytics tool. Its tracking script is under 1 KB — the smallest in the industry — and the Stats API lets you pull aggregate data for any metric and time range. The self-hosted option (via Docker) gives you complete data ownership.
Developer Highlights
- Stats API: Query timeseries, aggregate, and breakdown endpoints for visitors, pageviews, bounce rate, visit duration, sources, pages, countries, and more.
- Sites API: Programmatically create, update, and delete sites — useful for agencies or SaaS platforms managing many domains.
- Self-hosting: AGPL-licensed, Docker-based deployment. Full data sovereignty on your own infrastructure.
- Custom events: Track button clicks, form submissions, or any user action with the
plausible()JavaScript function. - Proxy-friendly: Official guides for proxying the script through Nginx, Caddy, or Next.js middleware to avoid ad-blocker interference.
Plausible's main limitation for developers is the lack of user-level or session-level data — everything is aggregate. If you need individual user tracking (for product analytics), you'll need a different tool.
Umami: Self-Hosted Analytics with a Modern Stack
Umami is a fully open-source analytics tool built with Next.js and PostgreSQL (or MySQL). It appeals to developers who want a modern tech stack they can understand, fork, and extend. Umami offers both a cloud-hosted service and a self-hosted option with one-click deployment to Vercel, Railway, or Docker.
Developer Highlights
- REST API: Comprehensive endpoints for websites, sessions, events, pageviews, and metrics. Token-based authentication.
- Modern stack: Built on Next.js, Prisma, and PostgreSQL. Easy to contribute to or customize if you fork the repo.
- One-click deploy: Deploy to Vercel, Railway, DigitalOcean, or Docker Compose in minutes.
- Event tracking: Track custom events with the
umami.track()function, including event properties for segmentation. - Teams and sharing: Built-in team management and shareable dashboard links.
Umami's weakness is scale. Self-hosting with PostgreSQL requires careful tuning at high traffic volumes, and the cloud offering is relatively new compared to Plausible's managed service.
PostHog: Full Product Analytics for Engineering Teams
PostHog is the heavy hitter. It goes far beyond web analytics into product analytics, feature flags, session recordings, A/B testing, and surveys — all self-hostable. If your team needs to understand not just traffic but in-product user behavior, PostHog is the most developer-friendly option in that category.
Developer Highlights
- Comprehensive API: Query events, persons, insights, feature flags, and experiments programmatically. The API supports HogQL (a SQL-like query language) for ad hoc analysis.
- Self-hosting: Deploy with Docker or Kubernetes on your own infrastructure. Open source under MIT license.
- SDKs everywhere: Official SDKs for JavaScript, React, React Native, Node.js, Python, Go, Ruby, PHP, Android, iOS, and Flutter.
- Feature flags: Roll out features to a percentage of users and measure impact without a separate feature-flag service.
- Data warehouse: Pipe PostHog data to your own warehouse (BigQuery, Snowflake, S3) via native integrations.
The tradeoff: PostHog's tracking script is significantly larger (around 60–90 KB depending on features loaded), and the self-hosted deployment is complex (Kubernetes recommended for production). It also uses cookies by default, though cookieless mode is available.
When to Choose PostHog
If you need product analytics (funnels, retention, cohorts, user paths) alongside web analytics, PostHog is the only open-source tool that covers both. For pure web analytics, it's overkill.
Installation: npm, Script Tag, or Both
Developers expect two installation paths: a script tag for static sites and an npm package for frameworks like Next.js, Nuxt, Remix, or SvelteKit. Here is how each tool handles installation.
Script Tag (Universal)
Every tool on this list supports a single script tag in your HTML <head>. For most sites, this is the fastest path to working analytics:
<script
defer
data-domain="yoursite.com"
src="https://copperanalytics.com/js/script.js"
></script>npm / Framework Integration
For React-based frameworks, you can load the script dynamically or use an official package. Here is a Next.js example using the Copper Next.js integration:
import Script from 'next/script';
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>
{children}
<Script
defer
data-domain="yoursite.com"
src="https://copperanalytics.com/js/script.js"
strategy="afterInteractive"
/>
</body>
</html>
);
}Plausible, Umami, and PostHog all follow a similar pattern. PostHog offers a dedicated posthog-js npm package with React hooks for feature flags and event tracking. Umami provides @umami/tracker for framework integration.
Ready to Try the API?
Copper Analytics's REST API is available on all plans, including the free tier. Get your API key and start querying in under 2 minutes.
Code Examples: Fetching Analytics Data via API
The real power of API-first analytics is programmatic access. Below are practical examples for fetching data from each tool's API.
Copper Analytics API
Fetch your site's top pages for the last 7 days:
const response = await fetch(
'https://copperanalytics.com/api/v1/stats/pages?' +
new URLSearchParams({
site_id: 'yoursite.com',
period: '7d',
limit: '10',
}),
{
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
}
);
const { data } = await response.json();
// data: [{ path: "/blog", visitors: 1420, pageviews: 2100 }, ...]Plausible Stats API
Query aggregate visitor stats for a specific date range:
const response = await fetch(
'https://plausible.io/api/v1/stats/aggregate?' +
new URLSearchParams({
site_id: 'yoursite.com',
period: 'custom',
date: '2026-02-01,2026-02-28',
metrics: 'visitors,pageviews,bounce_rate',
}),
{
headers: {
Authorization: 'Bearer YOUR_PLAUSIBLE_API_KEY',
},
}
);
const { results } = await response.json();
// results: { visitors: { value: 8500 }, pageviews: { value: 14200 }, ... }Umami API
Retrieve website metrics from a self-hosted Umami instance:
const response = await fetch(
'https://your-umami.example.com/api/websites/' +
'WEBSITE_ID/metrics?' +
new URLSearchParams({
startAt: String(Date.now() - 7 * 86400000),
endAt: String(Date.now()),
type: 'url',
}),
{
headers: {
Authorization: 'Bearer YOUR_UMAMI_TOKEN',
},
}
);
const metrics = await response.json();
// metrics: [{ x: "/blog", y: 1420 }, { x: "/docs", y: 890 }, ...]PostHog API (HogQL)
Run a HogQL query to get pageview counts grouped by path:
const response = await fetch(
'https://app.posthog.com/api/projects/PROJECT_ID/query/',
{
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_POSTHOG_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: {
kind: 'HogQLQuery',
query: `
SELECT properties.$pathname AS path,
count() AS pageviews
FROM events
WHERE event = '$pageview'
AND timestamp > now() - interval 7 day
GROUP BY path
ORDER BY pageviews DESC
LIMIT 10
`,
},
}),
}
);
const { results } = await response.json();
// results: [["/blog", 2100], ["/docs", 1450], ...]Headless Analytics: No Dashboard Needed
A growing pattern among developer teams is headless analytics— deploying a tracking script and consuming data exclusively through the API, without ever opening the vendor's dashboard. This approach treats analytics like any other data source: something you query, transform, and display in your own tools.
Common headless analytics workflows include:
- Slack bot integration: A cron job queries the analytics API every morning and posts a summary (visitors, top pages, top referrers) to your team's Slack channel.
- CI/CD gating: After deploying a new feature, query the API to check if error page views spike or if a specific conversion event drops below a threshold.
- Custom dashboards: Build a Grafana panel, a React dashboard, or a CLI tool that pulls data from the analytics API and displays exactly what your team needs.
- Weekly email reports: A serverless function queries the API, renders an HTML email template, and sends it to stakeholders via SendGrid or Resend.
- Data warehouse sync: Pipe raw analytics data into BigQuery, ClickHouse, or a Postgres table for cross-referencing with product or revenue data.
The key requirement for headless analytics is a comprehensive, well-documented API. All four tools covered in this guide support this pattern, but Copper Analyticsand Plausible offer the simplest API surface for pure web analytics use cases.
Pro Tip
If you adopt the headless approach, you still get the dashboard as a backup. The point is that the API is the primary interface, not the dashboard. This inversion is what makes analytics fit naturally into an engineering workflow.
Developer Tool Comparison
Here is how all four tools stack up on the criteria developers care about most:
| Feature | Copper | Plausible | Umami | PostHog |
|---|---|---|---|---|
| REST API | Full | Stats + Sites | Full | Full + HogQL |
| Script Size | <4 KB | <1 KB | ~2 KB | 60–90 KB |
| Cookies | None | None | None | Default on (opt-out) |
| Self-Hostable | No (cloud) | Yes (Docker) | Yes (Docker/Vercel) | Yes (Docker/K8s) |
| Open Source | No | AGPL | MIT | MIT |
| Free Tier | Yes (permanent) | Self-host only | Self-host or cloud free tier | Yes (generous limits) |
| AI Crawler Tracking | Built-in | No | No | No |
| Web Vitals | Built-in | No | No | Yes (via web-vitals) |
| Data Export | CSV + JSON API | CSV + API | API | API + warehouse sync |
| Product Analytics | No | No | No | Yes (full suite) |
Which Tool Should You Choose?
The right analytics tool for your dev team depends on the scope of what you need to track and how much infrastructure you want to manage:
- Choose Copper Analytics if you want the fastest path to working analytics with a full API, AI crawler visibility, Web Vitals, and data export — all without managing infrastructure. The free tier makes it zero-risk for side projects and startups.
- Choose Plausible if open source and self-hosting are non-negotiable. The sub-1 KB script is the smallest available, and the Stats API covers the most common web analytics queries.
- Choose Umami if you want to self-host on a modern stack (Next.js + PostgreSQL) and like the idea of deploying analytics alongside your app on Vercel or Railway.
- Choose PostHog if you need product analytics alongside web analytics — funnels, retention, feature flags, and session recordings in one platform. Accept the larger script size as the cost of a full-featured product suite.
For most developer teams building websites, blogs, documentation sites, or SaaS marketing pages, a lightweight web analytics tool (Copper Analytics, Plausible, or Umami) is the right fit. PostHog enters the picture when you cross the line from “I want to know my traffic” to “I want to understand in-product user behavior.”
For a deeper look at setting up Copper in a Next.js project, read our Next.js analytics setup guide. To explore data export options, visit the data export feature page.
The Developer Test
If you can install the tracking script, query the API, and get useful data into your terminal in under 5 minutes, the tool passes. If it requires a sales call, an onboarding wizard, or a 20-page docs deep-dive, keep looking.
Start Building with Copper Analytics
Privacy-first analytics with a full REST API, AI crawler tracking, and Web Vitals. No cookies. No consent banners. Free tier with API access included.
Get Started Free