Add Google Analytics 4 to the Velero website (#10583)
Run the E2E test on kind / setup-test-matrix (push) Failing after 4s
e2e-test-kind.yaml / extract (push) Failing after 8s
Run the E2E test on kind / get-go-version (push) Failing after 13s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 7s
Main CI / get-go-version (push) Failing after 7s
Main CI / Build (push) Skipped
Scorecard supply-chain security / Scorecard analysis (push) Skipped

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 <spampatt@redhat.com>
This commit is contained in:
Shubham Pampattiwar
2026-09-30 07:59:42 -07:00
committed by GitHub
parent e5d9354ddf
commit cfd7752dfd
4 changed files with 22 additions and 0 deletions
+1
View File
@@ -7,6 +7,7 @@ frontmatter:
date: [":filename", ":default"]
params:
author: Velero Authors
googleAnalytics: G-XX7MWLVX37
logo: Velero.svg
cncf_logo: cncf-color.svg
hero:
+1
View File
@@ -10,6 +10,7 @@
{{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
{{ block "siteTitle" . }}<title>{{ .Site.Title }} {{ .Page.Title }}</title>{{ end }}
{{ partial "google-analytics.html" . }}
</head>
<body id="{{ .CurrentSection.Params.id }}">
<div class="container-fluid site-outer-container">
@@ -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 }}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ . }}');
</script>
{{ end }}
{{ end }}
+1
View File
@@ -8,4 +8,5 @@
{{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
{{/* TODO {% seo %}*/}}
{{ partial "google-analytics.html" . }}
</head>