I want to host a Jekyll blog using GitHub Pages. I have purchased a license to display a web font for up to 50.000 page views/month. I order to not violate this agreement, I need to implement some kind of mechanism to count page views, so that I can take action whenever I reached 50,000 page views.
I have some rather complicated ideas in my head. On the one hand, I was thinking about performing a call to some AWS Lambda function that counts each page view, and takes action if it is one too many. On the other hand, I learned that MyFonts, Linotype and other font shops offer some of their web fonts using a licensing model called "pay-as-you-go", in which case they do mandate their customers to use a page view counter they provide, so that they can charge continuously, whenever certain quotas are hit. Their customers add those page view counters to their web sites by linking to a unique CSS file hosted by the respective font shop.
However, since I am probably not the only one having to deal with this, I wonder how other people solve this. My ideas seem to be a little over the top for what really is just a page view counter.
Is there an easier way? How is it commonly done?
There is a free API you can use with JavaScript to do this. I wear it and it works like a glove.
Basically you create a key (namespace) and each post for this route it increments 1. Then you can restore this count for display.
https://javascript.plainenglish.io/how-to-count-page-views-with-the-count-api-afc9369c1f8f