SEO Dashboard with Google Analytics Data


This report explores how we can pull in website data from Google Analytics and find insights on SEO. If you want to run this notebook, the install & setup instructions are kept in the



Google Analytics is a website traffic analysis application that provides real-time statistics and analysis of user interaction with the website. Google analytics enables website owners to analyze their visitors, with the objective of interpreting and optimizing website's performance.

In this report we will learn how to pull in the data using the Google Analytics Reporting API and graph some interesting SEO metrics to show meaningful insights for an online educational platform that has been running an extensive content marketing campaign for the last 18 months in order to drive more traffic to their website.

First let's import the libraries we will require:

Loading output library...

Create Globsal Variables For Data Access


If you haven't already, check out the file on this repository for instructions on how to creeate a project in the Google API Console, to enable the API, and create the key file, which you should save to this directory as client_secrets.json

Remeber to add the client_secrets.json file to your .gitignore!

Replace the VIEW_ID value below with your own. You can use the Account Explorer to find your View ID.

Fetching Our Data


Below we are initializing an Analytics Reporting API V4 service object with our credentials created above, defining our queries to the Google Analytics API and returning its response.



The Google Analytics Metric and Dimension Explorer is a great resource to use when searching for the dimensions and metrics you want to visualize, which will largely depend on your business and your digital marketing strategy.

Manipulating Our Data


Now let's parse the JSON response returend from our queries defined in the previous step into pandas dataframes, which will make it much easier to manipulate and graph the data.

Caching Our Data


Let's save everything to cache file so we dont need to download all the time. This is also handy to save data for APIs that have historical limits.

Has Our Organic Traffic Improved Over Time?


Let's visualize the progression of both organic and all other traffic to the website through time.

Loading output library...

Where Does This Search Result Traffic Land?

  • This company creates lots of different types of content to drive traffic to the website.
  • We want to know not only what pieces of content are getting the most results but also the type of content that is most successful.
  • Let's pull in the data we need to answer this question. We will look at the top 10 landing pages by pageviews, along with their bounce rates and average session durations.
Loading output library...
Loading output library...
  • We can see that guest blogs drive the most traffic overall.
  • However, this might be because there are simply more of these articles being published than Tutorials or Case Studies.

What Is The Quality Of The Content?

  • One way to proxy this is to calculate the distribution of session duration and bounce rates across our different types of landing pages.
  • We already have the data available so let's go straight into plotting.
Loading output library...
  • Indeed, we can see that, while guest blogs do receive much more eyeballs, the average session duration for this content is by far the lowest, and its avergae bounce rate is also the highest.
  • Tutorials seem to be the most valuable content to their readers according to these metrics.
  • Given the fact that guest blogs typically require payment of some kind, this company should seriously consider investing a lot more time and effort into case studies and tutorials.