Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Analytics with Matomo

24 Feb 2020 » docker, analytics, production, cloud

I am not big on the Google Ecosystem and realized I would like some sort of analytics embedded on my static sites to track which posts are doing well and which aren’t doing so hot. You’re being tracked! Does this scare you because it sure as hell scarese me! That’s were I found Matomo to take the place of Google Analytics.

It took me about 12 minutes to get a docker-compose file up and running.

Installation

Docker for the win. Matomo supports a docker image!

It requires a mysql backend but that’s easy enough to spin up using the latest mariadb image!

With docker-compose

mkdir matomo
cd matomo
touch docker-compose.yml
version: '3'
services:
  matomo:
    image: matomo:latest
    depends_on:
      - db
    ports:
      - "3000:80"
    volumes:
      - /matomo-data:/var/www/html
    environment:
      MATOMO_DATABASE_HOST: db
      MATOMO_DATABASE_ADAPTER: mysql
      MATOMO_DATABASE_USERNAME: matomo
      MATOMO_DATABASE_PASSWORD: matomo-secret
      MATOMO_DATABASE_DBNAME: matomo
  db:
    image: mariadb:latest
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: matomo
      MYSQL_USER: matomo
      MYSQL_PASSWORD: matomo-secret

Created this based off of my kanboard dockerfile and I had no problems. Also, subtle brag I got this spun up on the first try.

docker-compose up and it worked.

JS Tracking API

Right now I am not using the tracking API, but I am for sure going to check it out?

Tracking HTTP API

Still haven’t figured this out either… I will come back around to it eventually?

Client Configuration

HTTPS Required, but for the test environment this was a little annoying.

Firewalls

Make sure your firewalls aren’t busted. sudo ufw allow 80 and then sudo ufw allow 443 to allow traffic through.

NGINX Config

The NGINX Configuration was really annoying until I realized that it was the firewall causing the issue.

NGINX Let’s Encrypt

add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install python-certbot-nginx

sudo certbot --nginx -d matomo.itsltns.io

My Own Demise

I was using UblockOrigin and it blocked the script from loading, nice. I disabled the ublock script from taking place and the tracking worked.

© Jack Moore