From cfd7752dfd0ce485605bcb8232885d4d88dd18db Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Wed, 30 Sep 2026 07:59:42 -0700 Subject: [PATCH] Add Google Analytics 4 to the Velero website (#10583) Adds a gtag.js partial wired into both site head templates (baseof.html and head-docs.html) so every page on velero.io reports into a single GA4 property. The Measurement ID (G-XX7MWLVX37) is a CNCF-provisioned property for the Velero project (CNCF Service Desk CNCFSD-3824). The tag renders only in production builds, so local development and Netlify PR previews are excluded from the data. This also satisfies the CLOMonitor analytics check for our CNCF incubation work. Signed-off-by: Shubham Pampattiwar --- site/config.yaml | 1 + site/layouts/_default/baseof.html | 1 + site/layouts/partials/google-analytics.html | 19 +++++++++++++++++++ site/layouts/partials/head-docs.html | 1 + 4 files changed, 22 insertions(+) create mode 100644 site/layouts/partials/google-analytics.html diff --git a/site/config.yaml b/site/config.yaml index 9edc08541..781878b36 100644 --- a/site/config.yaml +++ b/site/config.yaml @@ -7,6 +7,7 @@ frontmatter: date: [":filename", ":default"] params: author: Velero Authors + googleAnalytics: G-XX7MWLVX37 logo: Velero.svg cncf_logo: cncf-color.svg hero: diff --git a/site/layouts/_default/baseof.html b/site/layouts/_default/baseof.html index 46d706fd2..e6910c6b9 100644 --- a/site/layouts/_default/baseof.html +++ b/site/layouts/_default/baseof.html @@ -10,6 +10,7 @@ {{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }} {{ block "siteTitle" . }}{{ .Site.Title }} {{ .Page.Title }}{{ end }} + {{ partial "google-analytics.html" . }}
diff --git a/site/layouts/partials/google-analytics.html b/site/layouts/partials/google-analytics.html new file mode 100644 index 000000000..c85bdbc70 --- /dev/null +++ b/site/layouts/partials/google-analytics.html @@ -0,0 +1,19 @@ +{{/* + Google Analytics 4 (gtag.js). + + Renders only in production builds (Netlify runs `hugo` with the production + environment, so local `hugo server` and PR previews stay out of the data). + The Measurement ID is read from `params.googleAnalytics` in config.yaml. +*/}} +{{ if hugo.IsProduction }} +{{ with .Site.Params.googleAnalytics }} + + + +{{ end }} +{{ end }} diff --git a/site/layouts/partials/head-docs.html b/site/layouts/partials/head-docs.html index c92837b2f..8cbb917ed 100644 --- a/site/layouts/partials/head-docs.html +++ b/site/layouts/partials/head-docs.html @@ -8,4 +8,5 @@ {{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }} {{/* TODO {% seo %}*/}} + {{ partial "google-analytics.html" . }}