Medium Statzler: Article Stats to Google Sheets & Excel

Nick Canfield
5 min readAug 19, 2020

--

Medium Statzler. Code to grab your Medium.com Stats with ease. Credits to Uyen Tran for image.

Hey “Medium”ites!

I’m been looking around for quite some time on how to download my Medium.com article stats to understand things such as:

  1. How much $$ am I making per day per article?
  2. How do my stories’ views compare to each other?
  3. On what publications do I make the most money?

However, I found that…

There really isn’t a good way to get these statistics, especially earnings data.

So that’s why I’ve created Medium Statzler, a free and easy way to grab your Medium.com stats.

I’ve also created a Google Data Studio dashboard template that you can use once you have your data ready in Google Sheets.

Google Data Studio Dashboard for the win!
Medium Statzler Logo. Credits to Uyen Tran for logo and branding.

Medium Statzler: What is it?

Medium Statzler is a Python script that:

  1. Logs into Medium.com (Automatically or with your manual login).
  2. Grabs your article stats from the homepage and articles’ pages.
  3. Posts the data into Excel and/or your Google Sheet.

Want to use it to grab your articles’ stats?

Let’s set it up!

How to Get Your Articles’ Stats with Medium Statzler

Video, if you like videos…

Step 0: Set up Python & PyCharm

— If you don’t know how to do this, please read my article Automating the Boring Stuff With Python (Example). It will guide you on how to set up PyCharm and Python.

— If you don’t want to do this, I’ll be making a .exe version that I will upload soon!

Step 1: Get the code

Go to my GitHub Repo Medium Statzler and grab the Main_Program.py file. It’s a beauty!

Where the Wild Code Things Are.

Of course, you’ll want to install the necessary packages. Do that before going to Step 2.

Step 2: Get your Google Authentication API .json file

To connect to Google Sheets from Python, you’ll need to allow get your Google Drive credentials set up.

How: Go to https://www.analyticsvidhya.com/blog/2020/07/read-and-update-google-spreadsheets-with-python/ and follow the steps on how to get your .json file. It’s a good tutorial!

Once you have your Google credentials .json file, save it to your computer and remember where you saved it. You’ll need the file path location for Step 5.

Step 3: Get Selenium ChromeDriver

You’ll need to get Selenium Chrome Driver to interact with the program in your web browser. I know… One more step to do.

How: Go to https://chromedriver.chromium.org/downloads and get the ChromeDriver version that matches your version of Google Chrome.

Which version should I get? Don’t know what version of ChromeDriver you need? Type “chrome://settings/help” into your Google Chrome address bar and find your Google Chrome version #.

Google Chrome version #. Make sure your ChromeDriver download matches this version!

Step 4: Setup Your Google Sheet

Use my Google Sheets datasheet template here to make your own Google Sheet in your Google Drive account. This will be the place where your Medium.com stats will be sent to.

Take note of what you name the workbook and sheet as you’ll need those for Step 5.

This is what your data sheet should look like. Don’t change the columns. If you want to create more stats based on this data, make it in columns “K” and onward.

Step 5: Insert Your Login / Google Sheets Data

Insert your login info and path variables into the beginning of the .py script.

I’ve tried to make the process as automated as possible to login with Google and get the stats. But to try it, make sure you insert your values into the ‘ ’ spaces where they go.

Step 6: Run Program and Interact with Opened Chrome Browser

Selenium Webdriver opens your web browser. Interact with the program in here and the terminal like below.
Screenshot of terminal. If the automatic Google login doesn’t work, login to Medium.com using the opened web browser. Once you’re on the Medium.com homepage, press enter in the terminal.

Follow the prompts to login to Medium.com. You might have to do 2-factor authentication, but however you get in, just make sure you can get your personal Medium.com page.

Once you’re logged in, the program will start grabbing your stats from the pages.

After you’ve logged in through the web browser, click enter in the terminal, and then let the program do its thing!

When it’s completed, you’ll see this:

Finished screen!

If you have any errors, google them and hopefully you’ll find the error reason.

If you saved your data to Excel, your file will open. :)

Step 7: Connect Data to Google Data Studio

Use my Google Data Studio template to make your own dashboard. Connect your Google Sheets to start tracking your stats.

There are many ways to analyze your articles’ data. If you want to get SUPER funky with it, you can do the change over time between dates for certain variables to get the amount you were earning on specific dates. #Calculus_For_The_Win!

Data for the win!!!

That’s it! Now you can get your Medium.com article stats automatically zipped into a Google Sheet / Excel file without having to copy/paste anything!

Woot Woot!

Notes:

  1. Kudos to Uyen Tran for making the logo and images.
  2. Medium might change their page layout anytime and mess this up, so please be patient if the program needs to be updated.

Updates:

(19-August 2020) — Wrote the article and made the GitHub repo!

--

--

Nick Canfield
Nick Canfield

Written by Nick Canfield

www.TropicFlare.com ➡ Business Automation www.GlobalHola.com ➡ Virtual Assistants 💼Entrepreneur 🌊🌴Digital Nomad https://domainwizard.ai

No responses yet