paint-brush
[Dev Update] Hacker Noon + Google Analytics = Happy Authorsby@austin
512 reads
512 reads

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

by Austin PocusOctober 4th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Hacker Noon has added an integration with Google Analytics to its stats page. The stats page will now show pageviews and total time reading for all stories published with Hacker Noon since we began in 2016. Previously, the stats page was only accessible for recent story performance. We're using v4 of the Google Analytics Reporting API to pull in the data. The hardest part was figuring out how to write the queries -- Google has a lot of documentation, but it's scattered and it’s a lot to wade through.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - [Dev Update] Hacker Noon + Google Analytics = Happy Authors
Austin Pocus HackerNoon profile picture

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!