paint-brush
HackerNoon Story Stats Update: Reads Powered By Cloudflareby@richardjohnn
1,176 reads
1,176 reads

HackerNoon Story Stats Update: Reads Powered By Cloudflare

by RichardApril 29th, 2022
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

58% of tech-savvy audiences block Google Analytics and so using Google Analytics (as we previously were) to gauge interest in story topics is problematic. Cloudflare has the advantage of being so integral to how our site’s content is delivered, that their servers’ get a chance to log the traffic before a client could ever block it. HackerNoon story stats readership numbers are now powered by Cloudflare Analytics.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - HackerNoon Story Stats Update: Reads Powered By Cloudflare
Richard HackerNoon profile picture


Writers, your story stats just got a backend lift! If you’ve published a story on April 20th, or since, you will probably see a larger number of reads on your stories. The reason for this is that we’ve started collecting data from Cloudflare Analytics. Why did we do this? For more accurate readership reports!


58% of tech-savvy audiences block Google Analytics and so using Google Analytics API (as we previously were) to measure readership per story is problematic. Cloudflare has the advantage of being so integral to how our site’s content is delivered, that their servers’ get a chance to log the traffic before a client could ever block it. Cloudflare’s approach counts a successful request to a URL delivering content of type HTML. In this way, we gain a straight forward view into story traffic.


“This doesn't mean you can go to your advertisers and start demanding more ad revenue. It should, however, mean that you now have a more accurate picture into the actual resource demands required to run your site.”

- Cloudflare’s Matthew Prince


Why not? Well, one reason is that Cloudflare includes more bot and crawler traffic in their analytics. Thankfully, we can filter page views by what Cloudflare calls a botManagementDecision

such that the traffic has been deemed to be “likely human” in origin. Are you a ‘likely human’ reading this story? Then you will count towards the reads at the top of this story page and writers will see that in their story stats. Here is the filter used in the GraphQL query:


      "pageviewsFilter": {
        "AND": [
          {
            "botManagementDecision": "likely_human"
          },
          {
            "datetime_geq": startDate,
            "datetime_leq": endDate
          },
          {
            "requestSource": "eyeball"
          },
          {
            "AND": [
              {
                "edgeResponseStatus": 200,
                "edgeResponseContentTypeName": "html"
              }
            ]
          }
        ]


This was my first time using GraphQL and while it looks like there is sort of living documentation supported, I had a hard time figuring out how to get the data I wanted. Most of their documentation was focused on firewalls and threat detection. I ended up opening up my browser’s network tab to see what requests were being sent as I changed filters while viewing their graphs on their own site. Thankfully, I was able to paste those into GraphiQL, an open source client to help you write queries, and verify I was getting the same page reads seen in the charts.


I really like the idea of using these server logs over downloading and executing javascript on the client. It is more efficient and less intrusive. It would be nice to remove the Google Analytics code from our site, but we still rely on it for tracking the time spent on pages and some click events. And keeping it on site just may help with search traffic ;-) Perhaps we’ll roll our own system there in the future.


Currently we still only fetch stats once a day, but I’ll be looking into fetching these stats more often so stay tuned for that. Okay, so that’s the update, enjoy! You should be seeing a lot less of these guys on your story now 🙂

Head on over to https://app.hackernoon.com/stats today and see for yourself!