Using API's from Google Analytics/Drive to extracting data unsampled (unsampled reports).
The unsampled reports created are available to download on Google Drive. An unsampled report is submitted to Google Analytics by APIs. So, this report is processed by Google and then is available to download on Google Drive. To download this report from Google Drive also is used the APIs. In both cases, I'm using the google-api-client (for python).
- python==2.7
- google-api-python-client==1.6.2
- httplib2==0.10.3
- oauth2client==4.1.0
- pyOpenSSL==16.2.0
You can use the following command: pip install -r requirements.txt
To submit an unsampled report to Google Analytics the API is authenticated using a service account. To download an unsampled report from Google Drive the API is authenticated using an user account.
For both cases, is necessary the JSON file (client_secret.json). This file you can generate in Google API Console.
These files were created for this specific project, but I can't share/ public them here because contains confidential data.
- get_profile_tvg.py
Returns Analytics data for a view (profile) in GA, using the API. The authentication method used by this script is service account.
- ins_unsampled_reports_tvg.py
Create a new unsampled report data in GA, using the API. The authentication method used by this script is service account.
- del_unsampled_reports_tvg.py
Delete an unsampled report data in GA, using the API. The authentication method used by this script is service account.
- list_unsampled_reports_tvg.py
List all unsampled reports to which the user has access in GA, using the API. The authentication method used by this script is service account.
- get_unsampled_reports.py
Returns a single unsampled report in GA, using the API. The authentication method used by this script is service account.
- download_unsampled_reports_tvg.py
Download unsampled reports created in GA, using the API. The authentication method used by this script is user account.
For more details about how to use this APIs: