There’s a cliché: “What gets measured, gets managed.” I’d argue that “what gets measured, gets measured” is more accurate, and it’s what I’m after here.
Setting the right goals
As I’ve written before, this site is built using the Grav CMS. Grav’s nifty admin plugin includes a simple dashboard that includes basic page view statistics; I thought I might be interested in having:
- longer-term metrics than what the CMS offers, and
- a little bit more granularity, specifically:
- which pages are getting viewed (and ideally, read),
- to have some sense of where that traffic comes from,
- what screen sizes/browsers are being used, etc.
Over time, knowing that will guide (to some extent) what I write, and (to a greater extent) what sorts of technical changes I might implement.
Client-side tracking with JavaScript
There are plenty of solutions available to get this sort of information: Google Analytics is the most famous and widely used of these, and it’s “free”. That is, there’s no credit card required or no signup fee to get started, and no monthly billing… at least up to ten million visits/month. (I might get 10 monthly visitors for the foreseeable future, so no worries there.)
Honestly, Google Analytics is very good at what it does. If you’re strongly invested in Google’s Marketing Platform, it makes good sense to serve Google Analytics and enjoy the tight integration. There’s a reason it’s the largest player by far in the web analytics sector, and the price tag isn’t the only reason. A product that isn’t any good—whatever the price point—doesn’t get that kind of market share.
Outside of my day job, I’m not heavily invested in Google’s offerings. (Fun
fact: The City of Edmonton was the first major municipal government in Canada to
switch to Google Apps G Suite Google
Workspace.)https://cloud.googleblog.com/2012/04/edmonton-is-first-major-canadian-city.html
Rather, it’s the size (in two respects) of Google Analytics that was my primary
reason for seeking out an alternative:
- Its feature set is way larger than I need or care about.
- (Therefore) the size of its tracking script is way larger than I need, and it is much larger than I’d like to ship.
Regarding 1): I don’t have sales funnels. I have no desire to bring additional datasets into my website analytics tool. The demographics of my readership is not something I’m especially interested in, at least not to end of making a profit. I don’t have a strong monetary interest in my readers. I’ve been through Google’s own training on Google Analytics (I’m certified, in fact); it’s a complicated tool with hundreds (literally hundreds) of reports and metrics. I’d rather tinker with other things. I’m not keen to monetize this site in any major wayI have some availability from October 2021. If you’d like to hire me or pick my brain, ping me., but I would like to keep an eye on what content here gets the largest share of my paltry traffic.
Regarding 2): client-side JavaScript is expensive, especially in terms of
downloading and CPU execution time. (See Addy Osmani’s
2018 essay
and
2019 essay/conference talk,
or
Tim Kadlec’s 2020 post
for details.) Google’s analytics.js
script weighs in at 49.4kB; its Tag
Manager script (part of Google’s recommended setup) gtag.js
is another 87.3kB.
The analytics.js
script would more roughly double the size of this page.
Privacy concerns about Google Analytics have both moral and technical ramifications. Google’s reliance on cookies means that Google can identify individual users across browser sessions and to track a user’s history and interactions with a given website over time. By using Google Analytics, you’re on the hook for putting into place (and keeping up to date) consent forms, disclosure notices, and a pretty extensive privacy policy. I have yet to meet a person who enjoys clicking on and configuring cookie preferences, so I’m not keen to subject anyone to any of that without a really good reason. Failure to do so is a liability, and I’m not keen to expose myself to undue risk, either.
If you still want to use Google Analytics
Update September 2023: If you do decide to go with Google Analytics anyway and you’re feeling a bit overwhelmed, a reader shared this resource from Website Planet with me by email (thanks, Emma!) as a recommended resource while setting up their recipe blog. Google Analytics 4 (GA4) replaces Universal Analytics (UA), which was sunset on July 1 of this year.
If somehow you’re reading this while in charge of a UA property and this is news to you, go update now. Your UA property hasn’t been collecting data for months. Note that the JavaScript for GA4 is a good bit larger than UA.
If you’re keen on using Google’s set of marketing tools anyway, and performance matters to you, and you’re reasonably comfortable in JavaScript (or very keen to learn), and you are willing and able to spend a probably not insignificant amount of time and effort to set up a custom, lightweight implementation, on the client, check out David Vallejo’s GA4MP project. A great overview of what kinds of things are involved in setting up GA4MP (and why they’re necessary) is available on Analytics-Toolkit.com.
Final Google Analytics remark: note, too, that they’re Analytics Toolkit is no longer supporting Google Analytics integrations, and that Google has established a reputation for sunsetting products, including their own A/B Testing tool, Google Optimize, which will stop working at the end of this month.
Alternatives
Of the “plenty” of solutions mentioned above, a subset of “privacy-focused analytics” tools and services have been growing in popularity in the last few years. They tend to be cookieless, and are considerably smaller in both script size and feature set. A search (yes, even in Google) will bring up a number of alternatives. To save you some searching:
- One good annotated list is available at privacyfocusedanalytics.info.
- Another is at this awesome-analytics github repository.
- Carl Cassar has a nice review post of a few options on his site.
I’ve gone with Plausible Analytics. Their script is just 1.4kB in size, while the platform gives me all of the features I’m interested in, with a much tidier interface than Google’s. Sure, some people use adblockers, and some disable JavaScript entirely. That’s fine. I’m interested in ballpark metrics over time; server-side analytics almost certainly overreport.
Plausible is open source, which is a plus in my books. I don’t mind paying a couple of bucks a month to support the service and enjoy the relatively hassle-free experience of dropping a script tag on the site, although it’s nice to have the option to self-host.
Contributing to open source
As for the process of inserting the script tag on a site, I went ahead and wrote a plugin to handle configuring the Grav-Plausible integration from within the Grav admin panel. Check that out on GitHub if you like.
That project represents my first couple of GitHub stars. Only three, at the time of writing, but it surely feels nice to build something useful and helpful to others. There couple of enhancements yet to go, although it’s perfectly functional as it is. Putting it together was a great learning experience, and has given me an idea for another plugin and a bit of a short-term content strategy…
Stay well; stay tuned.