Gyula recently asked for a decent cookieless analytics tool on Twitter:
Okay. I don't wanna use Google analytics, I don't wanna anger my users with cookie popups, but wanna be GDPR compliant and I wanna have analytics on my website at the same time.— GYN (@gyulanemeth85) November 1, 2023
What should I do? Any recommendations?
I suggested to use GoAccess to parse the nginx logs and create a HTML report and Hannes asked for a quickstart - so here we go.
Considering we're a running a Linux server with nginx and Docker, here's how to get started and our blog is static HTML generated with 11ty it is as easy as this to have a cron job running every day at 22:05 to create a HTML report of the nginx logs:
5 22 * * * cat /var/opt/deploy/logs/nginx/access.log | /usr/bin/docker run --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format COMBINED - > /var/opt/deploy/www/_site/report.html
The command in detail:
5 22 * * * - run the command every day at 22:05
cat /var/opt/deploy/logs/nginx/access.log - read the nginx access log
| - pipe the output to the next command
/usr/bin/docker run --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format COMBINED - - run the docker container with the GoAccess image and parse the nginx access log and create a HTML report
> /var/opt/deploy/www/_site/report.html - write the HTML report to the file system