<!-- Piwik -->
<script type="text/javascript">
    var _paq = _paq || [];

    <%# If this is a 404 page, provide additional information to Piwik - see http://piwik.org/faq/how-to/#faq_60 %>
    <% if @status.equal?(404) %>
        _paq.push(['setDocumentTitle', '404/URL = ' +
                String(document.location.pathname+document.location.search).replace(/\//g,"%2f") +
                '/From = ' + String(document.referrer).replace(/\//g,"%2f")]);
    <% end %>

    <%="_paq.push(['disableCookies']);" if @options[:disable_cookies] %>
    _paq.push(["trackPageView"]);
    _paq.push(["enableLinkTracking"]);

    (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<%= @options[:piwik_url] %>/";
        _paq.push(["setTrackerUrl", u+"piwik.php"]);
        _paq.push(["setSiteId", "<%= @options[: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>

<!-- Image Tracker -->
<noscript>
  <%# TODO set protocol (HTTP or HTTPS) based on the current protocol according to rack logic %>
  <img src="http://<%= @options[:piwik_url] %>/piwik.php?idsite=<%= @options[:piwik_id] %>&amp;rec=1" style="border:0" alt="" />
</noscript>
<!-- End Piwik -->