Web Analytics and Privacy

How do I get useful visitor metrics for my website while respecting the privacy of my users?

I was running my website (bakharzy.com) for about 5 months without running any web analytics tools such as Google Analytics. This means I had no idea about the number of page views, visitors, most viewed posts, and other useful interesting metrics.  

There were two main reasons for not opting in for any web analytics until now.  

Firstly, I just want to write, share, and learn from this process. If readers find my posts useful, that would be a great extra bonus for me.  

Secondly, I care about privacy. I have used Google Analytics in my previous projects, and it provides enormous number of stats, many useful and many more are not useful or necessary. Google Analytics is not privacy-friendly and tracks users across the web. Because I value privacy for myself as a user, I decided to respect the privacy of my users and not use Google Analytics.  

I have also been following Jussi Roine’s blog posts for a while and was inspired by his decision to disable Google Analytics on his blog and opt-in for a better solution (privacy-wise) such as Cloudflare web analytics. His decision was stuck in my mind, and I just wanted to give a shout-out to him for making this decision and more importantly sharing it. It inspired me to be more considerate of my users.  

Now, I am ready to learn more about the interaction of my users with my blog posts. For example, which posts are read more and number of visitors. The good news is that there are many Google Analytics alternatives nowadays that respect users’ privacy. Let us explore what I found out.  


Open-source and self-hosting 

A simple search on DuckDuckGo with the keyword “Google analytics alternatives” will bring up many different projects.  

I am a huge fan of open-source and self-hosted projects (e.g. Nextcloud). Naturally, I looked into a few different open-source web analytics projects. Plausible seemed to be a simple option for self-hosting. They also offer a cloud-hosted service for a fee. On their website, they say: 

“Plausible is privacy-friendly analytics. All the site measurement is carried out absolutely anonymously. Cookies are not used and no personal data is collected. There are no persistent identifiers. No cross-site or cross-device tracking either. Your site data is not used for any other purposes.” 

I also managed to find one negative review of Plausible. In overall, I think the self-hosted and trusted open-source projects are a suitable alternative for Google analytics. Many projects do not cookie the user at all. Of course, this means the metrics can be not 100% accurate, but that is a fine price to pay for privacy. I decided not to use a self-hosted project at this point because I do not have the time to host and maintain a web analytics service.  


The tool which I ended up testing and using is Cloudflare web analytics. First, I started using Cloudflare because of caching and DDoS protection. Then I remembered Jussi mentioning Cloudflare’s privacy-first web analytics. It is easy to set up the web analytics in Cloudflare if you are proxying your website behind Cloudflare. I did not even need to add the JS code to my site.  

Cloudflare do not use cookies or local storage to track users. They say in their website

“Cloudflare Web Analytics does not use any client-side state, such as cookies or localStorage, to collect usage metrics. We also don’t “fingerprint” individuals via their IP address, User Agent string, or any other data for the purpose of displaying analytics.” 

The metrics I receive on Cloudflare dashboard are number of visits, page views, page load time and some aggregated information about the users such as visits by country, browser, device, and OS. You can filter the metrics by different time intervals. The data retention period is unclear, and I could not find documentation about it. I read on some blog posts that retention is 7 days, but I believe the 7 days retention period has changed and it is at least 30 days now.  

Below are a few sample images of the dashboard.  

I am still new to Cloudflare and trying to make sense of its web analytics metrics. Additionally, Cloudflare provides a ton of other services. One that caught my attention is the email routing service which is still in beta. It lets you create custom email addresses with your domain and forward the emails to your current inbox. I tested this service and the forwarding works fine.  

I will write another blog post in future summarizing my experience with web analytics and other Cloudflare services.