analytics.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!-- Add Analytics if enabled in configuration -->
  2. {{ with site.Params.features.analytics }}
  3. {{ if or .enable .enabled }}
  4. {{ with .services }}
  5. <!-- Google Analytics -->
  6. {{ with .google }}
  7. {{ $privacyConfig:= dict (slice "Site" "Config" "Privacy" "GoogleAnalytics") $.Site.Config.Privacy.GoogleAnalytics }}
  8. {{ $analyticsConfig := dict (slice "Site" "Config" "Services" "GoogleAnalytics" "ID") .id }}
  9. {{ template "_internal/google_analytics.html" (merge $privacyConfig $analyticsConfig) }}
  10. {{ end }}
  11. <!-- Counter.dev -->
  12. {{ with .counterDev }}
  13. <script src="https://cdn.counter.dev/script.js"
  14. data-id="{{ .id }}"
  15. data-utcoffset="1"
  16. ></script>
  17. {{ end }}
  18. <!-- GoatCounter -->
  19. {{ with .goatCounter }}
  20. {{ with .code }}
  21. <script data-goatcounter="https://{{ . }}.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
  22. {{ else }}
  23. <script data-goatcounter="https://{{ .instance }}/count" async src="https://{{ .instance }}/count.js"></script>
  24. {{ end }}
  25. {{ end }}
  26. <!-- Piwik/Matomo -->
  27. {{ with .matomo }}
  28. <!-- Matomo -->
  29. <script>
  30. var _paq = window._paq = window._paq || [];
  31. /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  32. _paq.push(['trackPageView']);
  33. _paq.push(['enableLinkTracking']);
  34. (function() {
  35. var u="//{{ .instance }}/";
  36. _paq.push(['setTrackerUrl', u+'matomo.php']);
  37. _paq.push(['setSiteId', '{{ .siteId }}']);
  38. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  39. g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  40. })();
  41. </script>
  42. {{ end }}
  43. {{ with .cloudflare }}
  44. <!-- Cloudflare Web Analytics -->
  45. <script defer src='https://static.cloudflareinsights.com/beacon.min.js'
  46. data-cf-beacon='{"token": "{{ .token }}"}'
  47. ></script>
  48. <!-- End Cloudflare Web Analytics -->
  49. {{ end }}
  50. {{ with .umami }}
  51. <!-- Umami analytics -->
  52. <script defer src='{{ or .scheme "https" }}://{{ or .instance "analytics.eu.umami.is" }}/script.js' data-website-id="{{ .id }}"></script>
  53. <!-- End Umami analytics -->
  54. {{end}}
  55. {{ end }}
  56. {{ end }}
  57. {{ end }}
  58. <!-- Keep backwards compatibility and consistency with HUGO defaults -->
  59. {{ if .Site.Config.Services.GoogleAnalytics.ID }}
  60. {{ template "_internal/google_analytics.html" . }}
  61. {{ end }}