Google Analytics is a powerful tool that gives you useful insight about the traffic that arrives in your website. But together with Django, you will be able to retrieve data of your Analytics account and display it to the user, on demand.
In this post you’ll learn how to put together Django, the oauth2 protocol and the Google Analytics API.
In this post you will learn to create a Python script that allows users to enter its Google Analytics account and get information from there.
In order to do that, we will create a Project in the Google Developers Console and authorize it to use the Analytics API.
Next, we will use the Oauth 2.0 protocol to allow users to connect to their Analytics account through our Project.
And finally, we will retrieve the number of sessions of our view, segmented by traffic source.