Skip to content

ubyssey/google-analytics-super-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Analytics superProxy

The Google Analytics superProxy allows you to publicly share your Google Analytics reporting data. Use it to power your own custom dashboards and widgets, transform responses to various formats, manage your quota efficiently, test, and more. It handles authentication, caching, and response-formatting for you.

It works with the following Google Analytics APIs: Core Reporting API, Real Time Reporting API, and Multi-Channel Funnels Reporting API

Quick Links

Feature Highlights

  • Public access to your Google Analytics data
  • Use the proxy to power your own custom dashboards
  • Convert to CSV, Data Table, TSV
  • Relative dates are supported (e.g. last 7 days)
  • Automatically refreshes report data
  • Caching - fast responses and efficient quota usage

The Google Analytics superProxy is a web application that runs in the Google App Engine python environment.

Setting up a local development environment

  1. If necessary, download and install Python 2.7
  2. Download and install the App Engine SDK for Python
  3. Create an APIs Console Project.
  • Go to the Services pane to activate the Analytics API service.
    • Go to the API Access pane and create an OAuth 2.0 Client. For Client ID settings select Web Application. For the hostname click more options and then add the following to the Authorized Redirect URIs field: http://localhost:8080/admin/auth. Note: you may use a different port, but you need to use that port consistently throughout your project. Click on Create client ID.
  1. Edit config.py in the Google Analytics superProxy src directory. Update OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, and OAUTH_REDIRECT_URI with the corresponding values from the OAuth 2.0 Client you created in the previous step. The redirect URI does not need to include /admin/auth, this will be added for you.
  2. (Optional): The default the timezone for resolving relative dates is the Pacific timezone. The default setting for "anonymizing" Core Reporting API responses is set to False. Both of these options can be configured in src/controllers/util/co.py.
  3. Add the Google Analytics superProxy app to the Google App Engine Launcher (File->Add Existing Application) or start the app using dev_appserver.py. For additional details see The Development Environment. Make sure to serve the application using the same port as set in the list of Authorized Redirect URIs for your APIs Console Project, and in config.py.
  4. View the app by visiting http://localhost:8080/admin (replace 8080 with the correct port number).

Hosting the application on App Engine

  1. Setup the local development environment as described above.
  2. Register an application ID for your application using the App Engine Administration Console. This will give you a free hostname on appspot.com.
  3. Edit the app.yaml file in the src directory of the Google Analytics superProxy and set the first line to the application ID you registered in the previous step. E.g. application: your-application-id.
  4. Edit or create a new APIs Console Project and add the full URL of your application + /admin/auth as an Authorized Redirect URI for the OAuth 2.0 Client. If using the free appspot.com domain, the redirect URI will look something like https://your-applciation-id.appspot.com/admin/auth.
  5. Edit config.py in the Google Analytics superProxy src directory and update OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, and OAUTH_REDIRECT_URI if necessary.
  6. Using the Google App Engine Launcher or appcfg.py deploy the application. For details see Uploading Your Application.
  7. View the app by visiting the /admin page of your application. E.g. https://your-application-id.appspot.com/admin.

Creating your first public query

  1. See instructions above to get up and running, either with a local dev environment or on App Engine.
  2. View the application by visiting the /admin page. E.g. https://your-application-id.appspot.com/admin.
  3. Follow the instructions to authenticate and authorize the application to access your Google Analytics account.
  4. Create a new query (a Core Reporting API query URI) and specify:
  5. Click Save & Schedule Query to save the query and start scheduling the query for automatic refresh. A new Public Request Endpoint (URL) will be created for this report.

Requests to the public endpoint URL will return the API response for the specific report created. Authorization will not be required to access the report data and it will automatically refresh.

Features

  • OAuth 2.0 for authentication and it's all handled for you server side
  • Multiple users - each with their own set of queries
  • Automatic scheduling to refresh data at a configurable time interval
  • Caching of responses (saves on quota and it's fast)
  • API Query stats (last request time and number public requests)
  • Transform responses to CSV, Data Table, or TSV.
  • Relative dates are supported for reporting queries (e.g. last 7 days).
  • Timezone for relative dates can be configured (North American timezones and UTC).
  • Auto-scheduling. Scheduling for an "abandoned" API query (i.e. hasn't been publicly requested for a long time) will be automatically paused, resuming only if is subsequently requested.
  • Responses can "anonymized". If enabled, then Google Analytics profile IDs and other account information is removed from the public response.
  • Error logging. Errors for scheduled API queries are logged. After an API Query (default) has 10 error responses, scheduling for the query is paused.
    • The Google Analytics superProxy will not publicly return error responses. Instead the last successful response will be returned.
  • Public endpoints can be enabled/disabled if you want to stop sharing.
  • Queries can be be refreshed on an adhoc basis instead of waiting for the next scheduled refresh.
  • JSONP (add a callback parameter to the Public Endpoint request URL).

Changelog

2013-07-19

  • Initial launch...super sweet!

2013-08-06

  • Multiple Google Charts on a single page works again! (Fixes Issue #3)
  • Added a sample Google Charts HTML/JS demo.

About

Publicly share your Google Analytics reporting data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 83.2%
  • HTML 9.7%
  • CSS 3.6%
  • JavaScript 3.5%