Got a single page app deployed to an Amazon S3 bucket or Netlify and want to see how popular it is without polluting browsers with the tracking cookies? Just add a Cloudflare CDN layer on top.
The need for stats
Lately I have launched an online tool for base64 decoding-encoding. Main reason for it to exist was that I wanted to have a real fast online tool without any tracking cookies whatsoever.
Main reason for it to exist was that I wanted to have a real fast online tool without any tracking cookies whatsoever.
Even for a small private project done for fun it always feels much better if you can see whether the project is actually useful for anybody. I’d love to see how many people visit the tool and ideally how many of them do encode-decode, but how to do it without cookie-based tracking services and preferably without the need for the extra calls to the stats service?
Before the rise of the modern web stats services such as Google Analytics you could always check the web server own stats. Since your web server is returning an HTML, it can count how many times it returned this HTML.
Unfortunately in case of base64decode.tk and base64encode.tk as with most of the typical static JAM site server is beyond my control. I deploy straight from GitHub to Netlify. Netlify is an awesome service for front-end developers yet unfortunately until very lately there was no way to see the server-side stats of Netlify. A few days ago they have added basic server-side analytics, but it’s a paid feature and won’t work for a tiny hobby project.
Free server side stats for a static site
There is at least one CDN service that lets you see the request-related stats for free (within some limits that are quite generous for a hobby project) - Cloudflare.
If you tunnel Netlify through Cloudflare, you can enjoy the best of both worlds: have Netlify’s ease of deployment and Cloudflare’s access stats.
Setting up the Netlify-Cloudflare tunnel
Cloudflare’s domain setup wizard is done in such a way that it is significantly easier to set up your domain elsewhere first and add Cloudflare’s layer on top of it later and that’s what I did.
1. Set up your domain with Netlify
- Following the Netlify’s instructions tell your domain registrar to use Netlify’s name servers and validate the domain ownership.
- Wait until DNS information is propagated over the internet, it can take up to 24 hours, took something like 2-3 hours in my case.
2. Set up Clouflare as CDN in front of Netlify
Visit the Clouflare wizard, follow its instructions and change the name servers in your domain registrar to Cloudflare.
On Cloudflare’s side add DNS records to point to your Netlify-hosted site
Wait until it propagates over the internet again.
3. See the results.
Visit the Cloudflare’s analytics page and enjoy the stats! Not too much, but possibly good enough to see whether your project is of any interest at all yet with zero cookies and zero extra requests.
What do you think of the approach? Does it seem easy enough and efficient enough or is there be a simpler and better way?
So far I didn’t analyze the Netlify’s and Cloudflare’s privacy policies, what they actually track and how much they are GDPR compliant. I think they are compliant, but didn’t really study it yet. Do you happen to know if anybody has studied it already or would some research be needed here?