I did a massive upgrade to my personal website and decided to experiment an alternative to Google Analytics. My idea is to have insights (most visited pages, operating systems, browsers and referrals) about the visitors without any client-side code and cookie.
Google Analytics is still running on my website so I am able to compare the results of both solutions (assuming Google Analytics more accurate).
I duckDucked looking for a tool that can help me to reach this goal and the one that captured my attention was GoAccess.
The first thing to do, it is adding the Official GoAccess' Debian/Ubuntu Repository to our repositories. The version available on standard repository is really old. We have to follow the steps in the GoAccess documentation
$ echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list $ wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add - $ sudo apt-get update
After that we are able install the last available version (at the time of writing this post was 1.4)
$ sudo apt-get install goaccess
Add user to
It is a good idea to add the current user to
adm group so we do not
have to prefix
sudo to get permission to access. Remember to replace
myuser with your own Ubuntu user.
$ sudo usermod -g adm myuser
By default GoAccess listens on port 7890 for the WebSocket server. Ensure this port is opened. If you, like me, are running your server on DigitalOcean, you have to:
open your project and click on Networking (section Manage)
click on Firewalls tab and then click on your domain
add a Custom rule
Sources: All IPv4, All IPv6
Now that everything is set up we can run GoAccess. We can create a small script with our preferred configuration. The one below
ignores crawlers (
uses combined (the default for NGINX) log format (
displays real OS names (
outputs a realtime HTML dashboard
runs GoAccess as daemon (
#!/bin/bash clear echo "" echo "Starting GoAccess as daemon ..." echo "" goaccess /var/log/nginx/www.example.com-access.log \ -o /var/www/www.example.com/report.html \ --ignore-crawlers \ --log-format=COMBINED \ --real-os \ --real-time-html \ --ssl-cert=/etc/letsencrypt/live/example.com/fullchain.pem \ --ssl-key=/etc/letsencrypt/live/example.com/privkey.pem \ --daemonize echo "" echo "Running in background" echo ""
--ssl-key need because my server works over HTTPS.
I just deployed GoAccess, so it is still too early to say if it is exactly what I am looking for. That said, watching the the GoAccess dashboard I think I'm really close to what I need by adding some conditional logging to my NGINX configuration.