Matomo-Middleman

Gem Version

It's an extension for the Middleman static site generator to use Matomo tracking (previously known as Piwik).

Installation

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.

Configuration

In your config.rb you can configure the settings as follow:

activate :matomomiddleman do |p|
  p.domain = '<your-domain>'
  p.url = '<your-url>'
  p.id = 1
end

Helper

This plugin will add the following helper method:

<%= matomo %>

which will expand to

<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
  var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<your-domain>/<your-url>/";
  _paq.push(['setTrackerUrl', u+'piwik.php']);
  _paq.push(['setSiteId', 1]);
  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><p><img src="https://<your-domain>/<your-url>/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>