If you are using Google Analytics to analyze site traffic, you might want to embed those amazing dashboards to your website publicly. While Google doesn’t provide iframe solution, it does offer a Google Analytics Embed API which requires a bit more technical knowledge. I’ll walk you through each and every step and make sure you don’t have to read all developer documentation and can easily build dashboard

Python Server Implementation (Part)

Install Google API Client Library

sudo pip install --upgrade google-api-python-client

Return Google access token to client

# service-account.pyfromoauth2client.service_accountimportServiceAccountCredentials# The scope for the OAuth2 request.SCOPE='https://www.googleapis.com/auth/analytics.readonly'# The location of the key file with the key data.KEY_FILEPATH='path/to/json-key.json'# Defines a method to get an access token from the ServiceAccount object.defget_access_token():returnServiceAccountCredentials.from_json_keyfile_name(KEY_FILEPATH,SCOPE).get_access_token().access_token