feat(analytics): make Umami DNT behavior configurable

This commit is contained in:
undecV 2025-06-15 19:21:28 +08:00
parent 23a1baf96c
commit fe4e9b6163
No known key found for this signature in database
GPG key ID: 0C736668A96CC1D2
4 changed files with 9 additions and 1 deletions

View file

@ -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]

View file

@ -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

View file

@ -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 %}>
</script>
{% elif analytics_service == "plausible" %}

View file

@ -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]