Docs
Copper counts pageviews without cookies. One script tag per site, one dashboard for all of them.
Install the tracker
Create a project, then paste its snippet into the <head> of every page. The site key is on the project's settings page.
<script defer src="https://copper-analytics.vercel.app/c.js" data-site="YOUR_SITE_KEY"></script>The script is under 1.5 KB gzipped. It sends one request per pageview and follows client-side navigation in single-page apps on its own.
Next.js and Astro
In Next.js, add the component once in the root layout. It comes from the @copper-analytics/next package.
import { CopperAnalytics } from '@copper-analytics/next'
// app/layout.tsx, inside <body>
<CopperAnalytics siteKey="YOUR_SITE_KEY" host="https://copper-analytics.vercel.app" />In Astro, put the tag in a layout's head and keep it inline:
<script is:inline defer src="https://copper-analytics.vercel.app/c.js" data-site="YOUR_SITE_KEY"></script>Serve it from your own domain
Ad blockers may list any domain that contains the word analytics. Two rewrites on your own site avoid that. In next.config.ts:
async rewrites() {
return [
{ source: '/stats/c.js', destination: 'https://copper-analytics.vercel.app/c.js' },
{ source: '/stats/e', destination: 'https://copper-analytics.vercel.app/api/e' },
]
}Then load the script from your own path and point it at your own endpoint:
<script defer src="/stats/c.js" data-site="YOUR_SITE_KEY" data-api="/stats/e"></script>Opting out
- A visitor who runs
localStorage.setItem('copper_ignore', '1')in the browser console is no longer counted on that site. - A page that contains an element with a
data-copper-ignoreattribute is not counted. - Pages on
localhostandfile:pages are not counted, unless the script tag hasdata-dev.
What is counted
Visitors, pageviews, visits, bounce rate, top pages, referrer domains, countries, devices, browsers, operating systems and UTM sources.
A visitor is a hash of a random daily salt, the site key, the IP address and the browser's user agent. Only the hash is kept, and the salt is replaced at midnight UTC, so a visitor cannot be followed from one day to the next. For the same reason, visitors over several days are the sum of each day's unique visitors.
No cookie is set, nothing is written to the browser's storage, and no IP address or full URL is stored.
Stats API
Create a token on a project's settings page. It is read-only and works for that project alone.
curl -H "Authorization: Bearer <token>" \
"https://copper-analytics.vercel.app/api/v1/stats?site=YOUR_SITE_KEY&range=7d"range is one of today, 24h, 7d, 30d, 12mo or custom. With custom, add from and to as YYYY-MM-DD. The response has totals, previous and a series array.
Self-hosting
Copper is open source. One command starts a dashboard with a demo account and sample data:
git clone https://github.com/masaok/copper-analytics.git
cd copper-analytics
docker compose upThe self-hosting guide covers configuration and the Cloudflare-based mode for hundreds of sites.