• Download Python 2
• Register your application for the Analytics API in Google Developers Console
• Download the Google Python API Sample Code
• Google Analytics Query Explorer
• Python Code to Output Google Analytics API Query Data to CSV *save file as .py
R users check out this tutorial on how to pull your first Google Analytics R v4 reporting API query.
This guide will go through step by step instructions on how to setup Python and pull your first query directly from the Google Analytics reporting API. I will show you how to install Python on Windows and add the Google API Python library. We will create a new project in the Google Developers Console and enable the Analytics API. Next we will use a prebuilt sample Python application to get data out of Google Analytics via the API. Then I’ll walk you through how to test your own query using the Google Analytics Query Explorer. Then we will edit the Python application code to create your very own query. And finally we will pull Google Analytics data directly into Excel using Python to write a CSV file containing the Google Analytics data.