From fe4e9b6163839b1907d153fbf271b6abaff4459f Mon Sep 17 00:00:00 2001 From: undecV Date: Sun, 15 Jun 2025 19:21:28 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(analytics):=20make=20Umami=20D?= =?UTF-8?q?NT=20behavior=20configurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.toml | 3 +++ content/blog/mastering-tabi-settings/index.md | 2 ++ templates/partials/analytics.html | 2 +- theme.toml | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config.toml b/config.toml index fbcb337..4278538 100644 --- a/config.toml +++ b/config.toml @@ -372,6 +372,9 @@ service = "goatcounter" # Leave this field empty if you're using the service's default hosting. self_hosted_url = "https://tabi-stats.osc.garden" +# Optional: For Umami, enable this option to respect users' Do Not Track (DNT) settings. The default is true. +do_not_track = true + # giscus support for comments. https://giscus.app # Setup instructions: https://welpo.github.io/tabi/blog/comments/#setup [extra.giscus] diff --git a/content/blog/mastering-tabi-settings/index.md b/content/blog/mastering-tabi-settings/index.md index 19d9584..c80b463 100644 --- a/content/blog/mastering-tabi-settings/index.md +++ b/content/blog/mastering-tabi-settings/index.md @@ -811,6 +811,8 @@ You can set them up in the `[extra.analytics]` section of your `config.toml`. - For Umami: `"https://umami.example.com"` - For Plausible: `"https://plausible.example.com"` +- `do_not_track`: (Umami only) Optional. When set to `true`, the generated tracking script will include the `data-do-not-track="true"` attribute, which disables tracking for users whose browsers send a "Do Not Track" (DNT) header. + An example configuration for non-self-hosted GoatCounter would look like this: ```toml diff --git a/templates/partials/analytics.html b/templates/partials/analytics.html index 794e61b..6a5d30e 100644 --- a/templates/partials/analytics.html +++ b/templates/partials/analytics.html @@ -25,7 +25,7 @@ data-website-id="{{ analytics_id }}" src="https://cloud.umami.is/script.js" {% endif %} - data-do-not-track="true"> + {% if config.extra.analytics.do_not_track %}data-do-not-track="true"{% endif %}> {% elif analytics_service == "plausible" %} diff --git a/theme.toml b/theme.toml index 55bcd79..9761d73 100644 --- a/theme.toml +++ b/theme.toml @@ -320,6 +320,9 @@ custom_subset = true # Leave this field empty if you're using the service's default hosting. # self_hosted_url = "" +# Optional: For Umami, enable this option to respect users' Do Not Track (DNT) settings. The default is true. +do_not_track = true + # giscus support for comments. https://giscus.app # Setup instructions: https://welpo.github.io/tabi/blog/comments/#setup [extra.giscus]