Skip to content

Analytics

Canopy collects, stores and shows your app’s analytics itself. Nothing is sent to a third party.

Terminal window
canopy registry login --scope @canopy
bun add @canopy/analytics
import { CanopyAnalytics } from "@canopy/analytics/next";
// inside <body> of app/layout.tsx
<CanopyAnalytics />

Deploy, visit the site, and open the environment’s Monitoring page. No API key, environment id or environment variable is needed: Canopy matches the page’s address against the environment’s verified domains.

For 24 hours, 7, 30 or 90 days, with the change against the period before: visitors, sessions, pageviews, custom events, a time series, top pages, referrers, countries (with flags), custom events, recent events and Core Web Vitals. The page tells you when the last event arrived and which SDK version sent it. Preview deployments are not counted.

Page path (no query string), referrer, country, time, and the events and properties you send. No cookies and no stored identifier by default; visitors are counted with a hash that changes every day. IP addresses are used to look up the country and are not stored. Events are deleted after 90 days. Do Not Track and Global Privacy Control are respected.

Consent is yours to decide: <CanopyAnalytics consent={…} /> takes the visitor’s choice, and requireConsent holds events until it is granted. Read the full list in the SDK’s privacy notes.

import { track } from "@canopy/analytics";
track("signup_clicked", { source: "hero" });
<CanopyAnalytics clicks performance />
<button data-canopy-event="hero_cta">Get started</button>

On a custom domain Canopy serves, the browser posts to /_canopy/analytics/events on your own domain and Canopy’s edge forwards it, so the request is same-origin and needs no CORS. If that route is not there yet, the component falls back to api.canopy.pm on its own and no event is lost.

A site hosted elsewhere registers its hostname on the environment and passes the ids:

Register it with POST /environments/{environment_id}/analytics/origins ({"hostname": "shop.example.net"}) or the SDK’s environments.addAnalyticsOrigin.

<CanopyAnalytics environmentId="…" projectId="…" />

GET /environments/{environment_id}/analytics?range=30d (needs environment:read), or canopy.environments.analytics(id, { range: "30d" }) in the SDK.

  • A page’s country is approximate (DB-IP Lite, CC BY 4.0, db-ip.com).
  • Each environment accepts up to 6000 events a minute; excess is refused with 429 and a Retry-After.
  • Soft navigations are not measured separately for Core Web Vitals.