analytics.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!-- Add Analytics if enabled in configuration -->
  2. {{ with site.Params.features.analytics }}
  3. {{ if .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" "GoogleAnalytics") .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. <script
  21. data-goatcounter="https://{{ .code }}.goatcounter.com/count"
  22. async
  23. src="//gc.zgo.at/count.js"
  24. ></script>
  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. {{ end }}
  44. {{ end }}
  45. {{ end }}
  46. <!-- Keep backwards compatibility and consistency with HUGO defaults -->
  47. {{ if site.GoogleAnalytics }}
  48. {{ template "_internal/google_analytics.html" . }}
  49. {{ end }}