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.
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.
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.
(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.
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.
Setup the local development environment as described above.
Register an application ID for your application using the
App Engine Administration Console. This
will give you a free hostname on appspot.com.
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.
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.
Edit config.py in the Google Analytics superProxy src directory and
update OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, and OAUTH_REDIRECT_URI
if necessary.
Using the Google App Engine Launcher or appcfg.py deploy the application.
For details see
Uploading Your Application.
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)
请发表评论