How I check blog analytics without using Google Analytics
- Why stop using Google Analytics
- GoAccess: A privacy-concerned alternative to Google Analytics
- How do I get visits from my blog logs
- Don't miss any updates
Stop using Google Analytics is a decision I took when I started Code and Frames. I used Google Analytics in the past for other projects and I love all the information you can get. I still consider it is a great product, but as with any free product, it comes with trade-offs. In this post, I’m going to explain the nerdy alternative that I took to substitute Google Analytics.
Why stop using Google Analytics
These are my main concerns:
- Google has data about you and your visitors.
- It uses javascript so it delays page loading and performance. I wanted this site to be as Javascript-free as possible.
- It stores a cookie so, for GDPR compliance, you have to show a banner telling the user that the site uses cookies. I consider this very annoying as a web visitor.
In the case of Code and Frames, all I wanted to know is the amount of page views and visitors. Mostly to understand which topics perform well and which not. To achieve this I am using GoAccess.
GoAccess: A privacy-concerned alternative to Google Analytics
All the information about page views and visitors is already in the server logs. The only problem is that reading the logs is a pain in the ass. Fortunately, there is a tool that can help you parse the content. The name of this tool is GoAccess. You can easily generate a report from your server logs with this simple command:
goaccess $LOG_PATH/access.log -o report.html --log-format=COMBINED
How do I get visits from my blog logs
The command that I use is the following one. This allows me to see a report for a full month (in the example I get analytics for February 2021)
grep -E Feb/2021 $LOG_PATH/access.log | goaccess -o report.html --log-format=COMBINED
If I get a spike someday and want to know more information, I can filter by a specific date and see which posts performed better this day:
grep -E 03/Feb/2021 $LOG_PATH/access.log | goaccess -o report.html --log-format=COMBINED
Don't miss any updates
I write articles about coding, side projects, open-source, and creative tools. If you like this article, you can join the newsletter:
Quick script to update analytics
If I want to get a quick report, I run the following script report.sh
. In this I assume you can access via SSH to your site logs:
scp $MY_USER@$MY_DOMAIN.com:$LOG_PATH/nginx/access.log .
goaccess access.log -o report.html --log-format=COMBINED
rm access.log
open report.html
Trade-Offs of using GoAccess
Of course, this solution lacks a lot of functionality that Google Analytics has. I cannot see information like session time, the average time on a page, and others.
I am still quite a newbie with this tool, but I will be updating the trade-offs when I find more.
Next Steps
- Configure the script so I can see reports for specific days or months.
- Use redirection to gather information about clicks.