Skip to content

Commit

Permalink
feat: add umami analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
not-matthias committed Dec 24, 2024
1 parent f75ee7f commit b160dfe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
7 changes: 7 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ menu = [
{ name = "/linz", url = "/linz", weight = 1 },
{ name = "/about", url = "/about", weight = 2 },
]

# See https://github.com/not-matthias/apollo
[extra.analytics]
enabled = true

[extra.analytics.umami]
website_id = "4d764d5e-6d26-4286-b72a-a31637f3cdd5"
2 changes: 2 additions & 0 deletions static/js/imamu.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 3 additions & 12 deletions templates/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/jetbrains-mono.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/[email protected]/index.min.css">

{# Analytics #}
{# Analytics, taken from not-matthias/apollo #}
{% if config.extra.analytics.enabled %}
{% if config.extra.analytics.umami.website_id %}
{% set website_id = config.extra.analytics.umami.website_id %}
{% set host_url = config.extra.analytics.umami.host_url | default(value="https://analytics.eu.umami.is") %}
{% set host_url = config.extra.analytics.umami.host_url | default(value="https://api-gateway.umami.dev/") %}

<script>
(function () {
var el = document.createElement('script');
el.setAttribute('src', '/js/imamu.js');
el.setAttribute('data-website-id', '{{ website_id }}');
el.setAttribute('data-host-url', '{{ host_url }}');
document.body.appendChild(el);
})();
</script>
<script async src="/js/imamu.js" data-website-id="{{ website_id }}" data-host-url="{{ host_url }}"></script>
<script defer src="/js/imamu.js" data-website-id="{{ website_id }}" data-host-url="{{ host_url }}"></script>
{% endif %}

{% if config.extra.analytics.goatcounter.user %}
Expand Down

0 comments on commit b160dfe

Please sign in to comment.