This document explains how to use the Management API to access View (Profile) data.
A Google Analytics View (Profile) resource is at the third level in the Account hierarchy. Each View (Profile) has a single Webproperty resource as its parent in the hierarchy and can have a collection of zero or more Goal resources as children.
- Read the entity overview in the Management API overview guide to understand how views (profiles) relate to other Management API entities.
- Read the Accounts & Views (Profiles) conceptual guide for general information about views (profiles).
A Google Analytics View (Profile) is important because all reporting is done
at this level. When you query the
Core Reporting API you must specify a Table ID parameter in each
ids query to identify from which view (profile) to access data.
The Table ID parameter is returned in each View (Profile) resource.
Before You Begin
- Read the client libraries page for a complete list of programming language specific client libraries that work with the Management API.
- Read the Reference Guide to access the API without a client library
Each client library provides a single
Analytics service object
to access all Management API data. To create the service object
you generally have to go through the following steps:
- Register your application in the Google Developers Console.
- Authorize access to Google Analytics data.
- Create an
If you haven't completed these steps, please stop and read the Hello Google Analytics API Tutorial. This tutorial will walk you through the initial steps of building a Google Analytics API application. Once complete, you will be able to use this guide to perform real-world tasks.
The following code snippet continues from step 3: Create an Analytics service object and contains a variable to store an authorized service object.
Analytics analytics = // Read Hello Analytics Tutorial for details.
analytics = # Read Hello Analytics Tutorial for details.
$client = // Read Hello Analytics Tutorial for details. // Return results as objects. $client->setUseObjects(true); $analytics = new apiAnalyticsService($client);
The PHP library will return all the API results as an associative array. To return real
objects instead, you can call the client
as demonstrated in the example above.
Once you create an
Analytics service object, you are ready to make requests to
the Management API.
Note: The same
Analytics service object can also be used to access the
Core Reporting API.
Using A Test Account
If you intend to use the Management API to create and/or configure Views (Profiles), it's recommended that you implement and verify your code with a test account. Using a test account will help prevent you from making accidental changes to an active View (Profile). Once you've tested and confirmed that your code is working as expected using the test account and View (Profile), then you can start using the implementation with your real accounts.
You can create a test account in the Admin section of the Google Analytics web interface.
View (Profile) Limits and Behavior
The following limits and behaviors are applicable to the Profile resource:
- There is an upper bound of 50 views (profiles) per non-premium account and 200 views (profiles) per premium account. Once an account reaches the limit, additional views (profiles) cannot be created through the API unless one or more of the existing views (profiles) are deleted. In addition, existing views (profiles) can be updated and reused. See Limits and Quotas to learn about general limits.
- If all views (profiles) of a property are deleted then the property will no longer be visible in the Google Analytics web interface. See Web Property Limits and Behavior to learn more about the relationship between views (profiles) and properties.
The Management API allows you to list, get, insert, update, patch, and delete
views (profiles) for an authorized user. To use any of these methods, you
first need to create an
Analytics service object, as described in
the Before You Begin section.
For code examples that show you how to work with the Profile resource, visit the following method references:
- list — Lists views (profiles) to which the user has access.
- get — Gets a view (profile) to which the user has access.
- insert — Create a new view (profile).
- patch — Updates an existing view (profile). This method supports patch semantics.
- update — Updates an existing view (profile).
- delete — Deletes a view (profile).
See the Management API Reference Sample for a working example of how to traverse and access all the data in the Management API.
Google Analytics API Java client library Sample
Google Analytics API Python client library Sample
Google Analytics API PHP client library Sample