After I wrote about how to get a Jekyll blog up and running, I want to focus
on the next important bit: Analytics.

Since I don't want to leak the fact, that my blog was visited to Google et al.
I went for Piwik.

They offer a
5 minute installation guide
which took a bit more effort for me, because I am doing that for the first time.


Because Piwik expects PHP and MySQL, prepare a database and tweak your

Create a MySQL database

After a bit digging, you'll find that this is quite easy:

$ mysql
mysql> CREATE DATABASE <USER>_piwik;
mysql> EXIT;

Why <USER>_piwik? Because
Uberspace requires that prefix.

Tweaking php.ini

This one is
documented as well:

test -f ~/etc/php.ini || cp -a /package/host/localhost/php-$PHPVERSION/lib/php.ini ~/etc/
vim ~/etc/php.ini

As the docs explain, test -f checks, whether you already have a copied

Download and install

Download the latest zip using wget and
unpack it to ~/html as
first documented by Christian Vervoorts

mkdir -p ~/tmp && cd ~/tmp
mv piwik/ ../html

Now visit /piwik on your Uberspace instance and follow the instructions.
I had to only tweak two things:

  1. Removing something under piwik/plugins/Morpheus/
  2. Setting always_populate_raw_post_data = -1

Adding piwik.js

After you've completed your installation, you need to add the analytics script.

Therefore you could use
jekyll-analytics but I found it
has a small glitch regarding the path concatenation.

My patch made it into 0.1.5 and the following is no longer needed!

So I went a workaround:

<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  (function() {
    var u="///";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '']);
    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);
<!-- End Piwik Code -->

is saved as _includes/piwik.html.

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <meta name="description" content="undefined">

  <link rel="stylesheet" href="/assets/main.css">
  <link rel="canonical" href="/blog/2017/how-to-setup-piwik-on-uberspace/">
  <link rel="alternate" type="application/rss+xml" title="undefined" href="/feed.xml">
  { % include piwik.html % }<!-- remove the spaces there! Currently Jekyll interprets it! -->

overwrites the default _includes/head.html.

The _config.yml is adjusted as
described in jekyll-analytics.

For some reasons not all visits are tracked. I have no idea, why.


Now you are able to get basic analytics about your visitors.
This can be used to analyse, which articles went well and where you need more