%if config.get('piwik.site'):
    %if c.debug:
    <!-- Piwik: deactivated in debug mode -->
    %else:
    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(["trackPageView"]);
      _paq.push(["enableLinkTracking"]);

      (function() {
        var u="${config.get('piwik.site')}";
        %if not h.site.relative_urls():
        _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
        _paq.push(["setCookieDomain", "*.${h.site.domain()}"]);
        _paq.push(["setDomains", ["*.${h.site.domain()}"]]);
        %endif
        _paq.push(["setTrackerUrl", u+"piwik.php"]);
        _paq.push(["setSiteId", "${config.get('piwik.id')}"]);
        var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
        g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <noscript><img src="${config.get('piwik.site')}piwik.php?idsite=${config.get('piwik.id')}&amp;rec=1" style="border:0" alt="" /></noscript>
    <!-- End Piwik Code -->
    %endif
%else:
   %if c.debug:
   <!-- Piwik: no piwik site -->
   %endif
%endif
