Austin Pocus

Software engineer, cryptography student, and 👍 cat 👍 enthusiast. Happily hacking away @hackernoon!

[Dev Update] Hacker Noon + Google Analytics = Happy Authors

Austin here, your friendly neighborhood software engineer from Hacker Noon, with some exciting news! We are pleased as punch to announce that contributing writers can now see pageviews and total time reading for all stories published with Hacker Noon since we began in 2016. How cool is that? Previously our stats page was only accessible for recent story performance.
This Google Analytics integration means more accurate stats as well. Our pageviews in the original system, in particular, were skewed lower due to the need to load Firebase, and wait for user information to load, before recording a pageview.

Your Pageviews are going to go up! 

As for time reading, you may see slight variations in the numbers, comparing Sunday’s numbers to Monday’s, but there shouldn’t be a huge discrepancy (I mean, have you ever tried to measure time in Javascript?). Ultimately, Google Analytics is the source of truth here, so the new numbers will be more accurate.

How does it all work?

We’re using v4 of the Google Analytics Reporting API to pull in the data. Since we don’t have a traditional backend to speak of, I added a couple of endpoints to our own internal API server, which acts as a go-between (we couldn’t add the queries to the frontend, since the requests access site-wide data on GA). 
The hardest part was figuring out how to write the queries -- Google has a lot of documentation, but it’s pretty scattered and it’s a lot to wade through. In the end, though, we wound up using dimensions, along with dimension filter clauses, to find the stats for each user’s stories. In other words, if we use a dimension of ga:pagePath, we can use a dimension filter clause that specifies the page path should be included in an array of paths, in this case, story URLs.
Naturally, progress comes with a slight cost: when you visit the stats page for the first time, and maybe the second or third time, the stats will take a moment to load. However, once the request and its results are cached on Google’s end, the stats will load much faster. In the near future we hope to mitigate this with a caching system of our own.

Where do we go from here?

We have lots of exciting stuff in the funnel. Lets start at the bottom of the analytics funnel, you’ll soon be able to see the number of clicks your Writer Ad has received, from this point forward, giving you insight into how much traffic you’re driving to what you care about most (if you haven’t already, you should definitely set up a CTA!).
From there, we want to explore stats per tag. For example, if you use the “javascript” tag vs the “ecmascript” or “es6” tags, how does that affect traffic? I’d personally love to know this about my own posts!
There’s the graph we’ve planned from the beginning: showing words published vs time reading over time. With this new GA integration, we hope to bring you that graph in the near future.
Longer term we also want to improve the top of the funnel analytics. Wiith our auto-tweet system, other social channels, newsletters, SEO results, and more distribution systems, we can work towards providing headline impressions for all stories.
Mind you, these stats aren’t all going to happen immediately... but they’re near the top of our development funnel, meaning they live among many features that may or may not be developed in the future. 
That said, what sort of stats would you like to see? 
Tell us in the comments section!



October 4th, 2019

@austin Great work on this Google Analytics integration. When I look back on contributions to the internet, it’s cool to know that over 3+ months was spent reading my own Hacker Noon stories. Are you curious how long people have historically spent reading your stories? Time is our most valuable asset, and Hacker Noon now provides contributors with the total time readers spend on all their stories.

October 4th, 2019

Thanks @David! I feel a lot better about our stats page now that it’s powered by a robust, reliable source like GA, as opposed to a custom-built solution that, to be honest, didn’t get the time and attention it deserved (you know, because of the other million-and-one things to do :wink:).

Thanks to you too @arthur.tkachenko! Right now, it’s refreshing the first few times you open stats, and after that, Google appears to cache the response on their end. Of course, if you publish a new story, the query changes as does the response, so the cache is invalidated and the request must be made in full, again. We do intend to build out caching of our own, especially on this page, absolutely.

October 5th, 2019

3 months, 7 days, and 22 hours since moving to HackerNoon for me!

More by Austin Pocus

Topics of interest