From acdf51f7be4a091e5e9150bb9a6a74dae27f89f8 Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Thu, 30 Apr 2026 00:42:37 +0200 Subject: [PATCH 1/2] fix: skip Matomo tracking on localhost --- astro.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astro.config.mjs b/astro.config.mjs index dda0f7b4..fcf8be09 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -96,7 +96,7 @@ export default defineConfig({ }, { tag: "script", - content: `var _paq=window._paq=window._paq||[];_paq.push(["disableCookies"]);_paq.push(["enableLinkTracking"]);_paq.push(["trackPageView"]);(function(){var u="https://internetcomputer.matomo.cloud/";_paq.push(["setTrackerUrl",u+"matomo.php"]);_paq.push(["setSiteId","19"]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.async=true;g.src="https://cdn.matomo.cloud/internetcomputer.matomo.cloud/matomo.js";s.parentNode.insertBefore(g,s)})()`, + content: `if(location.hostname!=="localhost"&&location.hostname!=="127.0.0.1"){var _paq=window._paq=window._paq||[];_paq.push(["disableCookies"]);_paq.push(["enableLinkTracking"]);_paq.push(["trackPageView"]);(function(){var u="https://internetcomputer.matomo.cloud/";_paq.push(["setTrackerUrl",u+"matomo.php"]);_paq.push(["setSiteId","19"]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.async=true;g.src="https://cdn.matomo.cloud/internetcomputer.matomo.cloud/matomo.js";s.parentNode.insertBefore(g,s)})()}`, }, { tag: "script", From 746b94d669a5890bb7d70745441f57258a810f7b Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Thu, 30 Apr 2026 08:42:11 +0200 Subject: [PATCH 2/2] fix: move Matomo to public/matomo.js and skip tracking on localhost --- astro.config.mjs | 2 +- public/matomo.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 public/matomo.js diff --git a/astro.config.mjs b/astro.config.mjs index fcf8be09..36601834 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -96,7 +96,7 @@ export default defineConfig({ }, { tag: "script", - content: `if(location.hostname!=="localhost"&&location.hostname!=="127.0.0.1"){var _paq=window._paq=window._paq||[];_paq.push(["disableCookies"]);_paq.push(["enableLinkTracking"]);_paq.push(["trackPageView"]);(function(){var u="https://internetcomputer.matomo.cloud/";_paq.push(["setTrackerUrl",u+"matomo.php"]);_paq.push(["setSiteId","19"]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.async=true;g.src="https://cdn.matomo.cloud/internetcomputer.matomo.cloud/matomo.js";s.parentNode.insertBefore(g,s)})()}`, + attrs: { src: "/matomo.js", async: true }, }, { tag: "script", diff --git a/public/matomo.js b/public/matomo.js new file mode 100644 index 00000000..d22038bc --- /dev/null +++ b/public/matomo.js @@ -0,0 +1,17 @@ +if (location.hostname !== "localhost" && location.hostname !== "127.0.0.1") { + var _paq = (window._paq = window._paq || []); + _paq.push(["disableCookies"]); + _paq.push(["enableLinkTracking"]); + _paq.push(["trackPageView"]); + (function () { + var u = "https://internetcomputer.matomo.cloud/"; + _paq.push(["setTrackerUrl", u + "matomo.php"]); + _paq.push(["setSiteId", "19"]); + var d = document, + g = d.createElement("script"), + s = d.getElementsByTagName("script")[0]; + g.async = true; + g.src = "https://cdn.matomo.cloud/internetcomputer.matomo.cloud/matomo.js"; + s.parentNode.insertBefore(g, s); + })(); +}