Skip to content

Commit 3aa822a

Browse files
authored
Analytics docs rework: factor out UA-to-GA4 instructions, and more (#312)
1 parent 77d8246 commit 3aa822a

File tree

7 files changed

+58
-23
lines changed

7 files changed

+58
-23
lines changed

.htmltest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ TestFilesConcurrently: true
55
IgnoreDirs:
66
IgnoreInternalURLs: # list of paths
77
IgnoreURLs: # list of regexes of URLs or path to be ignored
8+
- ^https?://localhost
89
- \?no-link-check
910
# FIXME: temporary ignore rules
1011
- assistance\.md

docs/analytics/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Analytics
2+
3+
## Google Analytics
4+
5+
- [CNCF sandbox][] projects currently onboarding, should open a [Service Desk][]
6+
ticket to either:
7+
- Request a transfer of their existing GA properties to the **CNCF Projects**
8+
Google Analytics account. The first step is to make [email protected] and
9+
Administrator of their existing GA account.
10+
- Request the creation of a new analytics property.
11+
- For instructions on how to setup [Google Analytics 4 (GA4)][ga4] for your
12+
[Docsy][]-based website, see [Adding Analytics][].
13+
14+
> **Archived instructions**: for details on how to migrate from Universal
15+
> Analytics to GA4, see
16+
> [Migrating Universal to Google Analytics 4](ua-to-ga4.md).
17+
18+
[adding analytics]:
19+
https://www.docsy.dev/docs/adding-content/feedback/#adding-analytics
20+
[CNCF sandbox]: https://github.com/cncf/sandbox
21+
[docsy]: https://www.docsy.dev
22+
[ga4]: https://support.google.com/analytics/answer/10089681
23+
[service desk]: https://github.com/cncf/servicedesk
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@
22
cSpell:ignore: gtag kubernetes
33
---
44

5-
# Analytics
5+
# Migrating Universal to Google Analytics 4
66

7-
This page describes how to setup or upgrade Google Analytics (GA) for your CNCF
8-
project's website.
7+
This page describes how to migrate your CNCF project from Google's [Universal
8+
Analytics][ua] (UA) to [Google Analytics 4][ga4] (GA4).
99

10-
> **Deprecation notice**: Google's [Universal Analytics will be going away][ua]
11-
> in 2023.
12-
13-
When adding analytics to a new CNCF project website, use [Google Analytics
14-
4][ga4] (GA4).
15-
16-
## Adding Google Analytics
17-
18-
For instructions on how to setup [Google Analytics 4 (GA4)][ga4] for your
19-
[Docsy][]-based website, see [Adding Analytics][].
20-
21-
## Migrating to Google Analytics 4
10+
> **Deprecation notice**: Google started deprecating UA in 2023. As of 2024, UA
11+
> is no longer supported, and UA data is no longer accessible.
2212
2313
There are many ways to upgrade your project to [GA4][]. We describe one such
2414
process below. Adapt it to your needs. Useful resources to consider include:
@@ -30,7 +20,7 @@ process below. Adapt it to your needs. Useful resources to consider include:
3020
- **Help center** resource: [Migrate from Universal Analytics to Google
3121
Analytics 4][migration-help]
3222

33-
### Stage 0 - preparation
23+
## Stage 0 - preparation
3424

3525
In preparation for the migration, follow these steps:
3626

@@ -51,7 +41,7 @@ In preparation for the migration, follow these steps:
5141
- Take note of which library or libraries (some sites use both) your site is
5242
using.
5343

54-
### Stage 1 - create a GA4 site tag
44+
## Stage 1 - create a GA4 site tag
5545

5646
Objectives:
5747

@@ -138,7 +128,7 @@ Follow these steps:
138128
-- provided that there are active users. You should see roughly the same
139129
number and distribution of active users reported by the UA console.
140130

141-
### Stage 2 - configure the GA4 ID as the main analytics ID
131+
## Stage 2 - configure the GA4 ID as the main analytics ID
142132

143133
GA4 only works when your project's website is configured using the [gtag.js][]
144134
analytics library.
@@ -174,7 +164,7 @@ analytics library.
174164
partial. In this case, make use of the GA4 measurement ID in your partial
175165
or site config file, as appropriate.
176166

177-
### Stage 3 - switch to native support for GA
167+
## Stage 3 - switch to native support for GA
178168

179169
In cases where your project website (temporarily) used some custom layouts or
180170
code (such as custom Hugo partials) to enable GA4, consider removing the custom

docusaurus.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import type * as Preset from '@docusaurus/preset-classic';
77
const title = 'CNCF TechDocs';
88
const repo = 'https://github.com/cncf/techdocs';
99

10+
const buildEnv = process.env.BUILD_ENV || 'production';
11+
const isProd = buildEnv === 'production';
12+
1013
const config: Config = {
1114
title,
1215
// tagline: '',
1316
favicon:
1417
'https://www.cncf.io/wp-content/themes/cncf-twenty-two/images/favicon.ico', // TODO: localize?
1518

16-
// Production URL:
17-
url: 'https://cncf-techdocs.netlify.app/', // FIXME if/once we get a domain
19+
url: isProd
20+
? 'https://cncf-techdocs.netlify.app'
21+
: process.env.DEPLOY_PRIME_URL || 'http://localhost:3000',
1822
baseUrl: '/',
1923

2024
// GitHub pages deployment config. TODO: this still useful?
@@ -37,7 +41,7 @@ const config: Config = {
3741
{
3842
docs: {
3943
sidebarPath: './sidebars.ts',
40-
editUrl: `${repo}/tree/main`,
44+
editUrl: isProd ? `${repo}/tree/main` : undefined,
4145
},
4246
theme: {
4347
customCss: './src/css/custom.css',

netlify.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build]
2+
publish = "build"
3+
command = "npm run build:preview"
4+
5+
[context.production]
6+
command = "npm run build:production"

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0",
44
"description": "Resources provided by the CNCF Technical Documentation team.",
55
"scripts": {
6+
"_build": "docusaurus build",
67
"_check:format:any": "npx prettier --check --ignore-path ''",
78
"_check:format:delta": "npm run _check:format:any -- $(npm run -s _list:git:delta)",
89
"_check:format": "npx prettier --check .",
@@ -29,7 +30,9 @@
2930
"update:pkgs": "npx npm-check-updates -u",
3031
"docusaurus": "docusaurus",
3132
"start": "docusaurus start",
32-
"build": "docusaurus build",
33+
"build:preview": "npm run _build",
34+
"build:production": "npm run _build",
35+
"build": "BUILD_ENV=dev npm run _build",
3336
"swizzle": "docusaurus swizzle",
3437
"deploy": "docusaurus deploy",
3538
"clear": "docusaurus clear",

static/refcache.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@
255255
"StatusCode": 206,
256256
"LastSeen": "2025-03-19T11:52:38.95612-04:00"
257257
},
258+
"https://github.com/cncf/sandbox": {
259+
"StatusCode": 206,
260+
"LastSeen": "2025-04-22T19:39:31.8704-04:00"
261+
},
262+
"https://github.com/cncf/servicedesk": {
263+
"StatusCode": 206,
264+
"LastSeen": "2025-04-22T19:39:32.21738-04:00"
265+
},
258266
"https://github.com/cncf/tag-app-delivery": {
259267
"StatusCode": 206,
260268
"LastSeen": "2025-03-19T11:52:40.942477-04:00"

0 commit comments

Comments
 (0)