googleanalytics / google-analytics-super-proxy

Publicly share your Google Analytics reporting data.
Other
224 stars 99 forks source link

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

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.
  4. 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.
  5. (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.
  6. 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.
  7. 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

Changelog

2013-07-19