DEV Community

Cover image for Privacy first analytics with Cloudflare Web Analytics
Ayotunde Ikuesan
Ayotunde Ikuesan

Posted on • Originally published at tunde.io

Privacy first analytics with Cloudflare Web Analytics

> “We use cookies to track your activity across the internet and build a personalised profile about your interests, background and location so advertisers can sell you stuff you’re likely to be interested in but don’t actually need. Is that cool?”

No. I’m tired of having to reject all non-essential cookies from almost every single website I visit online. Similarly, when I’m building a website, the last thing I want to do is put anyone else through that burden. However, when I was building my website, I didn’t want to be without a way to track which pages and blog posts were popular and where my visitors were coming from… And I wanted to do it for free.

The natural choice was to go for Google Analytics, but apart from it now apparently being “illegal”, I’d be injecting one of the most invasive tracking cookies into my visitor’s browsers - which I wanted to avoid.

Introducing Cloudflare Web Analytics

The thing is, when something is free, you normally pay for it in some other way. Google Analytics is a free, effective service for tracking a wide array of site metrics, but it does so at the expense of user’s data. Cloudflare Web Analytics on the other hand is a totally free service that does not collect or use any personal data from users. The tool provides exactly all the information I’m looking for:

  • Page views
  • Popular browsers, devices & operating systems
  • Referrers
  • Geographical location of visitors (by country)
  • Core Web Vitals (LCP, FID, CLS)

For a low-traffic website like mine, there’s not much else I can ask for.

How does it work?

After signing up for a free account with Cloudflare, there’s two options for getting analytics working on your site.

If your domain’s DNS records are using Cloudflare’s nameservers, then you can simply select your domain from the admin interface and you’re good to go!

If not, then you’ll need to add a lightweight script to your website in order to start tracking.

‹script defer src="https://static.cloudflareinsights.com/beacon.min.js"
    data-cf-beacon='{"token":"your-script-token"}'>
‹script>
Enter fullscreen mode Exit fullscreen mode


If you test on multiple environments, no need to worry, as the tracking only applies to a single hostname you define — i.e. www.yourwebsite.com

The best thing about both of these methods, is that there’s no need for yet another cookie banner to find its way onto the internet! 🙌🏾

Is it enough?

For businesses, marketers and content creators trying to understand user behaviours and drive conversion rates, then it’s likely that Cloudflare Web Analytics won’t be enough. For example, I couldn’t find any options for tracking outbound button clicks. Also, data is restricted to 15 items on any report. So you’ll only see the top 15 pages, browsers, countries and so on, at any one time. Whether or not you decide to use CWA will come down to your own needs and assessment of the tool.

But if you are looking for a simple, free, privacy-focussed tool to track metrics on your website then Cloudflare Web Analytics is a pretty good option. However, if you don't mind paying and want a little more data & extra features, Plausible.io looks like another great option that maintains user's privacy.

Either way, leave the cookies in the cookie jar.

Cookie Monster peering in from the right.

Top comments (1)

Collapse
 
codewander profile image
codewander

Plausible analytics