It's an extension for the Middleman static site generator to use Matomo tracking (previously known as Piwik).
Clone the repository git clone [email protected]:wikimatze/matomo-middleman.git ~/git/matomo-middleman
.
Then add the following line to your Gemfile
:
gem 'matomo-middleman', path: "/home/wm/git/matomo-middleman/"
Run bundle install
.
In your config.rb
you can configure the settings as follow:
activate :matomomiddleman do |p|
p.domain = '<your-domain>'
p.id = '<your-id>
end
This plugin will add the following helper method:
<%= matomo %>
which will expand to
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//<your-domain>/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', "<your-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);
})();
</script>
<noscript><p><img referrerpolicy="no-referrer-when-downgrade" src="https://<your-domain>/matomo.php?idsite=<your-id>&rec=1" style="border:0" alt="" /></p></noscript>