I've been thinking about server-side analytics vs client-side. The other day I Tweeted:
I got a lot of different responses. Some folks prefer server-side and some prefer client-side. Most are unhappy with both! Some folks are upset that ad-blockers make it difficult to get good data. Other folks are finding clever ways of getting around ad-blockers. There is a lot to unpack here!
What's the problem?
Client-side analytics, on the other hand, get you access to a ton of information. Services like Google Analytics can capture exactly what users are doing on your website when they're doing it, and if they do it multiple times.
The only downside to using Google Analytics is that, as we've established, a lot of users have ad-blockers enabled which means you're not getting an accurate count of how many people are actually visiting your website.
Client-side vs Server-side comparison
Let's look at a few different metrics and compare the two options.
On the other hand, server-side analytics suffer from the opposite problem. User's with ad-blockers or JS disabled will show up in the dashboard, but so will a ton of bots and spam content.
This discrepancy can be massive. For example, this month on my personal blog Google Analytics (client-side) shows 1200 unique visitors but my Cloudflare Analytics (server-side) shows 7000 unique visitors. As much as I'd love Cloudflare to be right, I suspect the truth is somewhere in between.
Winner: Client-Side (Really the bots are winning)
Ease of use
Another point worth mentioning is that client-side analytics require JS to be sent on each request, slowing your website down. In some cases, this slow down can be negligible but it's worth mentioning that server-side analytics get you some tracking without adding any bloat to your website.
Website bundles are getting bigger every year. In fact, the average time it takes to fully render a web page is 1.5 seconds which means server-side analytics are going to be faster for your users even if you don't care about server costs.
If speed is a big issue for you, server-side analytics might be a better option to help improve your bounce rate and conversion.
What is a visitor, anyway?
There are a lot of bots on the web. Like, a lot. This report from Imperva claims that 61.5% of all web traffic comes from bots.
Compared to the previous report from 2012, we see a 21% growth in total bot traffic, which now represents 61.5% of website visitors.
This makes me feel like the client-side analytics numbers are closer to the truth. They might be a bit low due to ad-blockers, but server-side analytics numbers are very high because of bot traffic.
What are these bots doing?
The most common types of web traffic bots are:
- search engine crawlers (spiders and worms)
- content scrapers
- comment spammers
- sign-up bots
- malware bots
These bots are all looking for different things. Crawlers and scrapers are looking for content to copy or steal, comment spammers are trying to add links to their websites, sign-up bots are trying to create fake accounts, and malware bots are trying to infect your website.
Client-side server-side analytics
One final option is to be a little tricky. Ad-blockers work by maintaining a list of common ads and tracking endpoints and then blocking all requests to those endpoints. Check out this massive list of blocked endpoints and filenames.
These lists will have all the Google Analytics URLs blocked by default. If you really want to get around this, you can proxy all of your analytics requests through an innocent-looking endpoint. For example, you could use a service like Plausible to establish client-side analytics at a custom endpoint that these lists will not block.
Subscribe to my email list!
Let me be real with you. Sometimes when I'm bored I log in to Buttondown and look at the audience number. If it's bigger than it was the week before, well that makes me feel really happy! I promise I'll never spam you and I will, at most, send you a monthly update with what's happening on this site.