    <script>
      // Loads Matomo
      // See https://developer.matomo.org/api-reference/tracking-javascript
      function loadMatomo() {
        var _paq = window._paq = window._paq || [];

        _paq.push(['trackPageView']);

        {% if envvars('ANALYTICS_LINK_TRACKING') == '1' %}
        _paq.push(['enableLinkTracking']);
        {% endif %}

        {% if envvars('ANALYTICS_BROWSER_DETECTION') != '1' %}
        _paq.push(['disableBrowserFeatureDetection']);
        {% endif %}

        _paq.push(['disablePerformanceTracking']);
        _paq.push(['setDoNotTrack', true]);

        (function() {
          var u='{{ envvars('ANALYTICS_BACKEND') }}';

          _paq.push(['setTrackerUrl', u+'matomo.php']);
          _paq.push(['setSiteId',     '{{ envvars('ANALYTICS_SITE_ID') }}']);

          var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
          g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
        })();
      }

      // The 'Accept' button
      const consent = document.getElementById('consent-ok')

      // Handle the 'Accept' button
      consent.onclick = () => {
        // Hide the Consent UX
        banner.style.display = 'none'

        // Load Matomo
        loadMatomo()
      }
    </script>
