Netlify — Manual Setup
Add JustAnalytics to a Netlify-hosted site by setting environment variables and dropping in the tracking script.
Netlify — Manual Setup
JustAnalytics works on any Netlify site — the analytics, error tracking, and APM features do not depend on Netlify-specific glue. This page describes the manual setup that works today.
A Netlify Build Plugin that auto-injects the script and forwards deploy hooks as releases is on the roadmap — see Future Work below.
Time to data: 3 minutesPrerequisites#
- A JustAnalytics account with at least one site
- A Netlify site (any framework — Next.js, Astro, Hugo, Eleventy, vanilla static)
Step 1 — Add environment variables on Netlify#
In your Netlify site: Site settings → Environment variables. Add the following, sourced from your JustAnalytics dashboard's API Keys page:
JUSTANALYTICS_SITE_ID=cmkc0xbe70001fdge4feizme8
JUSTANALYTICS_API_KEY=ja_prod_XXXXXXXXXXXX
If you build with a Next.js / Astro / SvelteKit adapter and read the site ID in client code, also expose it with the framework's public-env-var prefix (e.g. NEXT_PUBLIC_…, PUBLIC_…, VITE_…).
Step 2 — Add the tracking script#
For a static site (Hugo, Eleventy, plain HTML), paste this into your root <head>:
<script
defer
src="https://justanalytics.app/tracker.js"
data-site-id="cmkc0xbe70001fdge4feizme8">
</script>
For a framework site, use the framework's normal head-injection point and read the site ID from the env var you set in Step 1.
Step 3 — (Optional) Map Netlify deploys to releases#
Netlify exposes the deploy ID and commit SHA as build-time env vars. Pass them to the SDK to get release tracking:
// e.g. in a Next.js instrumentation.ts or a Remix server-side init
JA.init({
apiKey: process.env.JUSTANALYTICS_API_KEY,
serviceName: 'my-netlify-site',
environment: process.env.CONTEXT ?? 'development', // 'production', 'deploy-preview', 'branch-deploy'
release: process.env.COMMIT_REF,
});
Netlify's standard build variables — CONTEXT, COMMIT_REF, BRANCH, DEPLOY_ID — are documented at https://docs.netlify.com/build/configure-builds/environment-variables/.
Verification#
Visit your deployed site in a new browser tab and watch the JustAnalytics dashboard — the visit should appear within seconds.
Future Work#
A Netlify Build Plugin (source already in this repo at packages/netlify-plugin/) will be published to the Netlify Plugin directory. When published, it will:
- Inject the tracking
<script>into every built HTML page during the build phase - Read
JUSTANALYTICS_SITE_IDfrom environment variables you set once in the Netlify UI - POST a release event to JustAnalytics on every successful deploy, tagged with
COMMIT_REF+BRANCH+CONTEXT - Optionally upload source maps for client-side bundles so error stack traces are deobfuscated
Until then, the manual setup above produces the same telemetry — you handle the script injection and release pings yourself.