Skip to content

Commit d798792

Browse files
committed
feat(docs): add Matomo analytics to documentation site
Add Matomo tracking to the docs site, matching the portal's setup (cookies disabled, link tracking enabled, same Matomo Cloud instance). The tracking script is deployed as a single root-level file (`/matomo.js`) rather than baked into each versioned build, so the site ID can be updated without rebuilding existing versions. > **TODO**: Replace `CHANGEME` in `docs-site/matomo.js` with the actual > Matomo site ID once IT creates the site for `cli.internetcomputer.org`.
1 parent 1277428 commit d798792

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ jobs:
8888
# Copy custom domain file
8989
cp docs-site/public/.well-known/ic-domains root/.well-known/ic-domains
9090
91+
# Copy Matomo analytics script (site ID defined once here, not per-version)
92+
cp docs-site/matomo.js root/matomo.js
93+
9194
# Extract the latest version from versions.json
9295
LATEST_VERSION=$(jq -r ".versions[] | select(.latest == true) | .version" docs-site/versions.json)
9396

docs-site/astro.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export default defineConfig({
5252
});
5353
`,
5454
},
55+
// Matomo analytics — loaded from root so the site ID is defined once,
56+
// not baked into each versioned build
57+
{
58+
tag: 'script',
59+
attrs: { src: '/matomo.js', async: true },
60+
},
5561
],
5662
social: [
5763
{ icon: 'github', label: 'GitHub', href: 'https://github.com/dfinity/icp-cli' },

docs-site/matomo.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var _paq = (window._paq = window._paq || []);
2+
_paq.push(["disableCookies"]);
3+
_paq.push(["enableLinkTracking"]);
4+
_paq.push(["trackPageView"]);
5+
(function () {
6+
var u = "https://internetcomputer.matomo.cloud/";
7+
_paq.push(["setTrackerUrl", u + "matomo.php"]);
8+
_paq.push(["setSiteId", "CHANGEME"]);
9+
var d = document,
10+
g = d.createElement("script"),
11+
s = d.getElementsByTagName("script")[0];
12+
g.async = true;
13+
g.src = "//cdn.matomo.cloud/internetcomputer.matomo.cloud/matomo.js";
14+
s.parentNode.insertBefore(g, s);
15+
})();

0 commit comments

Comments
 (0)