Web Dev Stories
AboutArticlesProjectsBookmarksContact

written on 11/04/2018

How to get total views and reads statistics on Medium

Ever been annoyed that you could not see your total views, total reads, and fans on your medium story stats page?

My stats page on medium
My stats page on medium

You can clearly see that the medium stats page is lacking a general overview area where you can see how your blog article performed over the whole lifetime of your blog. I was really annoyed about this particular issue but since I am a programmer I worked on a simple solution for everyone, especially you, could use to circumvent this problem.

The only thing that you need is a modern web browser. I recommend using Chrome or Firefox. The first thing you have to do is to go to your stats page which you can reach by browsing to https://medium.com/me/stats. After you have done this you need to open the developer tools of your browser.

Chrome:

  • Mac: Command + Option + J ( ⌘ + ⌥ + J)

  • Linux and Windows: Control+Shift+J

Firefox:

  • Mac: Command + Option + K ( ⌘ + ⌥ + K)

  • Linux and Windows: Control + Shift + K

After you have opened the console you need to paste the following script:

1
const totalTypes = {
2
VIEWS: 2,
3
READS: 3,
4
FANS: 5
5
};
6
7
const getTotal = tableColumn =>
8
[
9
...document.querySelectorAll(
10
`td:nth-child(${tableColumn}) > span.sortableTable-number`
11
)
12
]
13
.map(e => parseInt(e.getAttribute("title").replace(/,/g, ""), 10))
14
.reduce((a, b) => a + b, 0);
15
16
console.log({
17
totalViews: getTotal(totalTypes.VIEWS),
18
totalReads: getTotal(totalTypes.READS),
19
totalFans: getTotal(totalTypes.FANS)
20
});

You can find the source code of this script also here: https://gist.github.com/igeligel/b2e1ab401ed3f96dcf1030045224fb2c

After inserting the script and pressing enter you should end up with a result like this:

Results in the developer tools
Results in the developer tools

In the last line, there is something written which is undefined but do not bother about it. The line above is more important because there you can see the aggregated data about total views, total reads and total fans which might be interesting for you.

I hope this article helped you a bit and I really hope medium is going to work on those statistics pages a lot and give us writers more insights into the data. Medium is still a great platform and I enjoy to write blogs here.

Thanks for reading this. You rock 🤘 If you have any feedback or want to add something to this article just comment here. You can also follow me on twitter or visit my personal site to stay up-to-date with my blog articles and many more things.

You might also like

© Kevin Peters 2021

Imprint