The Google Analytics APIs allow you to access data within Google Analytics. It should not be confused with the measurement protocol which is used for inserting data into Google Analytics.
The Google Analytics API is split into serval parts.
Google Analytics Reporting APIs
The Google Analytics Core Reporting API v3 gives you access to most of the report data in Google Analytics. With the Core Reporting API you can:
The Google Analytics Reporting API V4 is the most advanced programmatic method to access report data in Google Analytics. With the Google Analytics Reporting API, you can:
The Real Time Reporting API enables you to request real time data—for example, real time activity on a view—for an authenticated user. You can use the Real Time Reporting API to:
The Real Time Reporting API, in limited beta, is available for developer preview only. Sign up to access the API.
The Multi-Channel Funnels Reporting API enables you to request Multi-Channel Funnels data for an authenticated user. Data is derived from conversion path data, which shows user interactions with various traffic sources over multiple sessions prior to converting. This allows you to analyze how multiple marketing channels influence conversions over time. For more details on what data is available, read the About Multi-Channel Funnels, as well as About Multi-Channel Funnels Data. With the Multi-Channel Funnels Reporting API you can:
Helpers
The Metadata API returns the list and attributes of columns (i.e. dimensions and metrics) exposed in the Google Analytics reporting APIs. Attributes returned include UI name, description, segments support, and more. You can use the Metadata API to:
Note: This only returns metadata for the Core Reporting API and the Reporting API. Not real-time metadata.
Configuration APIs
The Analytics Management API allows for programmatic access to the Google Analytics configuration data. You can build applications to more efficiently manage large or complex Analytics accounts. Large companies with many properties can automate account setup. Even if you are building a reporting application the Management API provides you tools to navigate your account. You can use the Google Analytics Management API to:
Write operations in the Management API (e.g. create, update, delete, patch) for Web Property, View (Profile), and Goal resources is currently available as a developer preview in limited beta. If you're interested in using these features, request access to the beta.
The Provisioning API is available by invitation only. We are not currently accepting new projects.
The Google Analytics Reporting API V4 is the most advanced programmatic method to access report data in Google Analytics. With the Google Analytics Reporting API, you can:
Features
Google Analytics is built upon a powerful data reporting infrastructure. The Google Analytics Reporting API V4 gives you access to the power of the Google Analytics platform. The API provides these key features:
In order to access any Google API you need to identify yourself as a developer and identify your project. We do that by creating a new project on Google Developers console.
When you create your project you if you want to access the Google Analytics APIs you must enable the APIs you intend to access.
Now you must decide how you would like to access the data.
With Google Data there are two types of Data Public and Private.
If you are only accessing public data then all you need do is create a public API key and you will be able to access the API in question. If you are going to be accessing private user data then you will need to create either Oauth2 credentials or service account credentials.
Authorization Oauth2
To access private user data we must have permission of the owner of the data to access it. Oauth2 allows us to request that access from a user.
You have probably seen before Oauth2 before.
The Application "Google Analytics Windows" is requesting access to view the users "Google Analytics Data"
Scope We need to tell the user what we intend to do the Google analytics API has two scopes that you can use.
It is best to only request the scopes that you need. If you will only be reading a users data then you only need to request the readonly scope.
Authorization service accounts
Service accounts are different in that they are pre-approved. If you create service account credentials you as the developer can take the service account email and add it as a user on your Google Analytics account At the account level this will grant the service account access to the data. You wont need to pop up the authentication window and request access. The service account will have access to the data for as long as it is a user on the Google Analytics account.
Conclusion
Authentication is needed to access most of the data exposed by the Google Analytics API.
You can not use client login / login and password to access any Google API as of May 2015. You must use Open authentication.
**
The Metadata API returns the list and attributes of columns (i.e. dimensions and metrics) exposed in the Google Analytics reporting APIs (v2,v3 and v4). Attributes returned include UI name, description, segments support, and more.
You can use the Metadata API to:
This is the same list as is in the Dimensions & Metrics Explorer.
Note: Real-time and Multi-Channel Funnels dimensions and metrics are not currently available.
The Real Time Reporting API, in limited beta, is available for developer preview only. Sign up to access the API.
The Real Time Reporting API enables you to request real time data—for example, real time activity on your property—for an authenticated user.
You can use the Real Time Reporting API to:
Authorization
Calls to the Google Analytics Real-time API requires authorization with at least one of the following scopes (read more about authentication and authorization).
Scope | access granted |
---|---|
https://www.googleapis.com/auth/analytics | Full access to Google Analytics accounts up to the level of the authenticated users access. |
https://www.googleapis.com/auth/analytics.readonly | Read only access to the Authenticated users Google Analytics accounts |
If an request is successful, the API returns a 200 HTTP status code along with the requested data in the body of the response.
If an error occurs with a request, the API returns an HTTP status code and reason in the response based on the type of error. Additionally, the body of the response contains a detailed description of what caused the error.