{% if matomo_url and matomo_id %}
  <!-- Begin Matomo tracking -->
  <script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
  var u = "{{ matomo_url }}";
  _paq.push(['setTrackerUrl', u + 'piwik.php']);
  _paq.push(['setSiteId', '{{ matomo_id }}']);
  var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
  g.type = 'text/javascript';
  g.async = true;
  g.defer = true;
  g.src = u + 'piwik.js';
  s.parentNode.insertBefore(g, s);
})();
  </script>
  <!-- End Matomo tracking -->
{% else %}
  <!-- No matomo_id or matomo_url found %} -->
{% endif %}
