-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Display posts ranked by GoatCounter visitor count — is there a better approach? #2695
Description
Checklist
- I have read and accepted the contributing guidelines.
Is your feature request related to a problem? Please describe
There's no built-in way to display posts and categories ranked by visitor count. Posts are typically listed chronologically, which doesn't help visitors discover the most popular or relevant content on the site. I'd like a way to surface posts by actual readership using GoatCounter analytics data.
Describe the solution you'd like
I've built a custom page that displays posts and categories ranked by visitor count using GoatCounter analytics.
Live demo: https://linsnotes.com/popular-posts/
Source: https://github.com/kuibinlin/kuibinlin.github.io/blob/main/_pages/popular-posts.html
How it works
- Client-side JS fetches visitor counts from the GoatCounter API
- Matches hit counts to posts by URL path
- Renders posts sorted by popularity
- Groups and aggregates counts by category
It works fine for my use case, but I wanted to check — is there a better or more recommended approach for this? Specifically:
-
Data fetching — I'm hitting the GoatCounter API on every page load. Is there a cleaner way to pull this data, or a built-in feature I might be overlooking?
-
Caching — Currently no caching. Would it make sense to cache the response client-side with a TTL, or is the API lightweight enough that it doesn't matter?
-
Fallback — Right now if GoatCounter is unreachable the page just shows nothing. Any suggestions on graceful degradation?
-
Integration — Is there an existing plugin, theme feature, or community pattern that already solves this more elegantly?
Open to any feedback or suggestions.
Describe alternatives you've considered
No response
Additional context
No response