The tracking module injects Google Analytics (GA4 / gtag.js) into your site's <head>. It is automatically included — no manual template setup is needed.
Set your Google Analytics measurement ID in config.scriban:
site.tracking.google.id = "G-XXXXXXXXXX"
Both GA4 (G-...) and legacy Universal Analytics (UA-...) IDs are accepted.
When active, the module emits two <script> tags in the page <head>:
googletagmanager.comgtag('config', '<your-id>')The tracking snippet is emitted only when both conditions are met:
site.environment == "prod" (case-sensitive — "Prod" or "PROD" will not match)site.tracking.google.id is set to a truthy valueThis makes lunet serve safe by default — it runs in dev mode, so no analytics code is injected during development.
When building for production, use lunet build (which defaults to prod environment) or set the environment explicitly.
The tracking snippet is rendered from the include file _builtins/google-analytics.sbn-html. You can override this file by placing your own version at .lunet/includes/_builtins/google-analytics.sbn-html in your site. This lets you customize the tracking code (e.g. adding custom dimensions or event parameters).
<head> meta tag injectionsite.environment and other site properties