My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google Analytics (Labs)

Developer's Guide

With the Google Analytics Data Export API, you can develop client applications to request data from an existing Analytics profile for an authorized user, and refine the results of the request using query parameters. Currently, the Data Export API supports read-only access to your Google Analytics data. The current feeds in the Data Export API contain two general categories of Analytics data:

  • Analytics account and profile data
  • Analytics report data from a single profile

This developer's guide contains information on the following:

  • Getting Started—Analytics access and feed retrieval basics
  • Quota Policy—our usage policies
  • Protocol—underlying protocol used by all client libraries
  • Java—developer guide for the Java client library
  • JavaScript—developer guide for the Javascript client library

The Google Analytics Data Export API is currently in public beta. While in public beta, our API will remain subject to change. In most cases, we will do our best to give customers at least one month advance notice to migrate to new API releases before we remove or deprecate old functionality. In unusual cases such as where our internal systems are affected or our ability to provide a high level of service to our end users, we reserve the right to make changes on shorter notice. As usual, usage of our API is ultimately governed by our Developer Terms of Service.

Getting Started

To use the Analytics Data Export API, you need access both to an existing Google Analytics account and to the profile that tracks your website use. Users of your application will also need similar access. You will get the most information when you use the Data Export API to export data from an Analytics profile that has been collecting traffic for a period of time.

Accessing an Analytics Account

If you don't yet have a Google Analytics account, sign up for one. Analytics uses Google Accounts, so if you already have a Google Account, you can use that ID to set up an Analytics account. Once you have signed up, follow the instructions for setting up the tracking code for your website. Before using the Analytics Data Export API to retrieve statistics from a newly-created Analytics profile, be sure to check your Analytics reports to ensure that you have data available for display in the feeds.

For more information on Google Accounts and Analytics accounts, see the documentation on Accounts & Profiles.

Feed Retrieval Basics

It's important to understand the relationship between an Analytics account and the profiles within that account. After reading the documentation on Accounts & Profiles, you can better understand how data is obtained for a feed.

These three basic steps summarize the process your application should follow in order to retrieve Analytics feed data from your website.

  1. Authentication

    Users who access your application must be logged in to Analytics. Typically, your application will ask them to supply their login credentials. If your application is written for a specific Analytics profile, your users should have access to both the account and the profile within that account. For profile access, only read-level permission is necessary. Your users will log in with their Google Accounts email and password. For example: liz@gmail.com.

  2. Account Query

    Once your application has verified that the user has Analytics access, its next step is to find out which Analytics accounts the user has access to. Remember, users can have access to many different accounts, and within them, many different profiles. For this reason, your application cannot access any report information without first requesting the list of accounts available to the user. The resulting accounts feed returns that list, but most importantly, the list also contains the account profiles that the user can view.

  3. Profile/Report Query

    The profile is the gateway to Analytics reports. From the list of available profiles, your application can request report data to display to your user. The key ingredient to this request is the ID for the profile supplied in the account feed. You can see this ID in the Analytics web interface in the Profile Settings screen.

    The account feed returns this value to you in the dxp:tableID field, which contains the ID of the profile, along with a namespace prefix. Until you have this ID, you cannot get data for the reports, because a report query requires this table ID.

Because it is the profile that is associated with a website, you will always need to use the table ID in order to get feed data. First retrieve an account feed in order to obtain the list of profiles available to the user of your application. If you supply the account ID in your request instead of the table ID, your query will fail.

Quota Policy

Before using this release of the Google Analytics Data Export API for your applications, be aware of our quota policy.

The Google Analytics Data API accepts millions of operations. To protect the system from receiving more operations than it can handle, and to ensure an equitable distribution of system resources, it's necessary to employ a quota system. Our policies are subject to change, but currently they are as follows:

  • The quota applies to a single web property
  • 10,000 requests per 24 hours
  • 10 requests in any given 1-second period
  • A query is also limited to pagination limits of 10,000 entries per feed, with a default response of 1,000 entries

The Data Export API uses the web property ID as its reference for a web property, not an individual profile ID. This means that your application can only make 10k requests per day for all the profile IDs that track the same web property by ID. For example, suppose your website uses UA-1234-1 as its ID: that ID has a quota assigned to it.

Every single profile that tracks the website draws from that same quota pool.

Now suppose profiles 1 and 2 track this site. On Monday, profile 1 could draw all the quota, and on Tuesday, profile 2 could draw all the quota. On Wednesday, the quota allowance could be split between the two profiles. Any combination is allowable, because the maximum allowance is set to the web property itself, not the particular profile. For more information about web properties and web property IDs, see "Web Property" in the Accounts and Profiles document.

When an account has exceeded its quota, an authorized request for a feed results in an HTTP 503 (Service Unavailable) response, with a message in the body of the response indicating that the specific account has insufficient quota to proceed. See the terms of service for more information.