GoatCounter¶
Privacy-friendly analytics for your sites
GoatCounter is an open source web analytics platform available as a free, donation-supported hosted service or self-hosted app.
It aims to offer easy to use and meaningful privacy-friendly web analytics as an alternative to Google Analytics or Matomo.
This guide installs the application at ~/goatcounter/. The service is named
“goatcounter”, uses port 8080 internally and is exposed at stats.example.com. It logs to the systemd
journal. This guide uses SQLite.
Installation¶
Download and install the linux-amd64.gz variant and extract it to ~/goatcounter.
Example output is abbreviated:
[isabell@moondust ~]$ mkdir -p ~/goatcounter
[isabell@moondust ~]$ cd ~/goatcounter
[isabell@moondust goatcounter]$ wget -O goatcounter.gz https://github.com/arp242/goatcounter/releases/download/v2.7.0/goatcounter-v2.7.0-linux-amd64.gz
[...]
[isabell@moondust goatcounter]$ gzip -d goatcounter.gz
[isabell@moondust goatcounter]$ chmod +x goatcounter
Create the directory for the SQLite database. GoatCounter creates the database when it starts:
[isabell@moondust ~]$ mkdir -p ~/goatcounter/db
Create a systemd service to run GoatCounter in the background and start it automatically after a reboot. Example output is abbreviated:
[isabell@moondust ~]$ uberspace service add goatcounter "%h/goatcounter/goatcounter serve -listen :8080 -tls http -db sqlite+%h/goatcounter/db/goatcounter.sqlite3" --workdir "$HOME/goatcounter" --directive Restart=always --directive RestartSec=5
OK: Created service file: /home/isabell/.config/systemd/user/goatcounter.service
OK: systemctl --user daemon-reload
OK: systemctl --user start goatcounter.service
OK: systemctl --user enable goatcounter.service
OK: systemctl --user status goatcounter.service
[...]
Add a domain and create a web backend to make the service available:
[isabell@moondust ~]$ uberspace web domain add stats.example.com
[isabell@moondust ~]$ uberspace web backend add stats.example.com PORT 8080
Do not forget to add the DNS entries!
Web Interface¶
GoatCounter provides a web interface which displays analytics.
Open stats.example.com and complete the setup wizard
to create your first site and user account. Replace stats.example.com throughout
this guide with your own domain.
Add the tracking code shown in GoatCounter to the website you want to monitor.
Backup¶
Stop GoatCounter while backing up the entire data folder ~/goatcounter/db so that its SQLite databases are not changing
during the backup. Restart it afterwards:
[isabell@moondust ~]$ systemctl --user stop goatcounter
[isabell@moondust ~]$ tar -cf - ~/goatcounter/db | zstd - > goatcounter.tar.zstd
[isabell@moondust ~]$ systemctl --user start goatcounter
Updates¶
Note
Check the release feed regularly for new versions.
To update GoatCounter, download the new version and replace the executable. Replace 2.7.0 in the installation commands with
the version you want to install. Example output is abbreviated.
[isabell@moondust ~]$ cd ~/goatcounter
[isabell@moondust goatcounter]$ wget -O goatcounter.gz https://github.com/arp242/goatcounter/releases/download/v2.7.0/goatcounter-v2.7.0-linux-amd64.gz
[...]
[isabell@moondust goatcounter]$ gzip -dc goatcounter.gz > goatcounter.new
[isabell@moondust goatcounter]$ chmod +x goatcounter.new
[isabell@moondust goatcounter]$ mv goatcounter.new goatcounter
[isabell@moondust goatcounter]$ rm goatcounter.gz
Finally, restart the service and check its status:
[isabell@moondust goatcounter]$ systemctl --user restart goatcounter
[isabell@moondust goatcounter]$ systemctl --user status goatcounter