Summary: This document provides a high level overview of the Google Analytics Admin API Version 1.0.
Introduction
The Google Analytics Admin API allows for programmatic access to the Google Analytics 4 (GA4) configuration data and is only compatible with GA4 properties. Learn more about GA4 properties.
You can use the Google Analytics Admin API to:
- Provision new accounts
- List, Manage, and Delete accounts
- List account summaries
- List, Create, Manage, and Delete GA4 properties.
- Change Google Analytics data sharing settings for GA4 properties.
- Create, Manage, and Delete Web, Android, iOS data streams inside GA4 properties.
- Generate a Global Site Tag snippet for Web data streams inside GA4 properties.
- Manage enhanced measurement settings for Web data streams inside GA4 properties.
- Manage Links between GA4 properties and Firebase projects.
- Manage Links between GA4 properties and Google Ads accounts.
- Manage user permissions for an account hierarchy and GA4 properties.
- Audit user permissions including implicit ones that come from effective permissions granted by groups or organization admin roles.
Available methods
Account provisioning
Account management
Account summaries
User permissions management
- accounts.userLinks.list
- accounts.userLinks.create
- accounts.userLinks.batchDelete
- accounts.userLinks.batchCreate
- accounts.userLinks.get
- accounts.userLinks.patch
- accounts.userLinks.batchUpdate
- accounts.userLinks.delete
Account data sharing settings management
User permission audit
GA4 properties management
Firebase project linking
- properties.firebaseLinks.delete
- properties.firebaseLinks.patch
- properties.firebaseLinks.list
- properties.firebaseLinks.create
Google Ads account linking
- properties.googleAdsLinks.delete
- properties.googleAdsLinks.patch
- properties.googleAdsLinks.list
- properties.googleAdsLinks.create
GA4 data streams management
- properties.androidAppDataStreams.delete
- properties.androidAppDataStreams.get
- properties.androidAppDataStreams.patch
- properties.androidAppDataStreams.list
- properties.androidAppDataStreams.create
- properties.webDataStreams.delete
- properties.webDataStreams.list
- properties.webDataStreams.create
- properties.webDataStreams.get
- properties.webDataStreams.patch
- properties.iosAppDataStreams.delete
- properties.iosAppDataStreams.get
- properties.iosAppDataStreams.patch
- properties.iosAppDataStreams.list
- properties.iosAppDataStreams.create
Global Site Tag generation
Enhanced measurement settings management
- properties.webDataStreams.updateEnhancedMeasurementSettings
- properties.webDataStreams.getEnhancedMeasurementSettings
Enable the API
Click this button to automatically enable the Google Analytics Admin API:
Enable the Google Analytics Admin APIQuick start guide
Quick start using client libraries
API discovery document
You can query the Google Analytics Admin API discovery document by using the following URL:
https://analyticsadmin.googleapis.com/$discovery/rest?version=v1alpha
Client libraries
See the Quick start guide for examples of using the client libraries.
Java
If you are using Maven, add this to your pom.xml file:
<dependency> <groupId>com.google.analytics</groupId> <artifactId>google-analytics-admin</artifactId> <version>0.1.1</version> </dependency>If you are using Gradle, add this to your dependencies
compile 'com.google.analytics:google-analytics-admin:0.1.1'
Python
Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions.
With virtualenv, it’s possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.
pip install virtualenv
virtualenv
source <your-env>/bin/activate
<your-env>/bin/pip install google-analytics-admin
Node.js
npm install @google-analytics/admin
Ruby
gem install google-analytics-admin-v1alpha
Go
go get -u cloud.google.com/go/analytics/admin/apiv1alpha
.NET
If you are using Package Manager, execute this command:
Install-Package Google.Analytics.Admin.V1Alpha -Version 1.0.0-alpha01If you are using .NET CLI, execute this command in your project's folder:
dotnet add package Google.Analytics.Admin.V1Alpha --version 1.0.0-alpha01You can directly include the library dependency to your project by adding this to your .NET project file:
<PackageReference Include="Google.Analytics.Admin.V1Alpha" Version="1.0.0-alpha01" />
Changelog
2020-08-15 Client libraries have been updated. Please refer to the quickstart samples and reference documentation for the corresponding libraries. Client library artifacts are now published to external repositories.
2020-08-15 Google Analytics Management App + Web API has been renamed to the Google Analytics Admin API. As a result, the API endpoint has changed to analyticsadmin.googleapis.com. Existing code written against the previous version of the API endpoint url and client libraries needs to be updated accordingly.
2020-10-13 App + Web properties have been renamed to Google Analytics 4 (GA4).
2020-10-20 Added support for account summaries.
2021-01-28 Breaking changes:
update_mask
field is required for all Update operations.country_code
field renamed toregion_code
inAccount
.url_query_parameter
field renamed touri_query_parameter
inEnhancedMeasurementSettings
.parent
field removed fromGoogleAdsLink
.
2021-01-28 Pagination support added for
ListFirebaseLinks
operation.