# Managing Google Analytics Properties with the Admin API: A Complete Developer Guide

> Programmatically manage Google Analytics properties accounts and data streams with the Admin API. Follow this guide to enable the API configure credentials and call endpoints.

- Repository: [Google/skills](https://github.com/google/skills)
- Tags: developer-guide
- Published: 2026-08-15

---

**You can programmatically manage Google Analytics properties, accounts, and data streams using the Admin API with a three-stage workflow: enable the API service, configure Application Default Credentials, and call endpoints through official client libraries.**

The Google Analytics Admin API skill in google/skills provides a production-ready template for automating analytics infrastructure tasks. This guide walks through the complete implementation based on the canonical skill definition at [`skills/analytics/google-analytics-admin-api-basics/SKILL.md`](https://github.com/google/skills/blob/main/skills/analytics/google-analytics-admin-api-basics/SKILL.md).

## Enabling the Admin API Service

Every Admin API workflow starts with service activation. The skill mandates explicit enablement through the Google Cloud CLI before any programmatic calls.

Run this command to enable `analyticsadmin.googleapis.com`:

```bash
gcloud services enable analyticsadmin.googleapis.com --quiet

```

Verify successful enablement:

```bash
gcloud services list --enabled --filter="analyticsadmin.googleapis.com"

```

This two-step verification prevents runtime authentication errors that occur when developers skip service activation.

## Configuring Authentication and Scopes

The Admin API skill relies on **Application Default Credentials (ADC)** for all authentication flows. ADC automatically resolves credentials from environment variables, service accounts, or user credentials without hardcoding keys.

Required OAuth scopes depend on your operation type:

- `https://www.googleapis.com/auth/cloud-platform` — Base Cloud platform access
- `https://www.googleapis.com/auth/analytics.readonly` — Read-only analytics data
- `https://www.googleapis.com/auth/analytics.edit` — Create, update, or delete resources

As documented in [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md) lines 42-48, set these scopes when initializing your credential provider:

```bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json

```

For local development, use:

```bash
gcloud auth application-default login \
  --scopes=cloud-platform,analytics.readonly,analytics.edit

```

## Installing Client Libraries

The skill provides language-specific setup guides across seven runtimes. Installation commands for the most common environments:

### Python

```bash
pip install google-analytics-admin

```

Full reference: [[`references/python.md`](https://github.com/google/skills/blob/main/references/python.md)](https://github.com/google/skills/blob/main/skills/analytics/google-analytics-admin-api-basics/references/python.md)

### Node.js

```bash
npm install @google-analytics/admin

```

Full reference: [[`references/nodejs.md`](https://github.com/google/skills/blob/main/references/nodejs.md)](https://github.com/google/skills/blob/main/skills/analytics/google-analytics-admin-api-basics/references/nodejs.md)

### Java, Go, .NET, Ruby, PHP

The skill maintains dedicated reference files for each runtime in the `references/` directory, covering Maven/Gradle coordinates, Go modules, NuGet packages, gem specifications, and Composer requirements respectively.

## Listing Accounts and Properties with Python

The canonical first operation—demonstrated in [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md) lines 90-100—retrieves all accounts and their child properties accessible to the authenticated principal.

```python
from google.analytics.admin import AnalyticsAdminServiceClient

def list_account_summaries():
    """Prints a summary of all GA accounts and properties visible to the caller."""
    client = AnalyticsAdminServiceClient()  # ADC must be configured

    
    for summary in client.list_account_summaries():
        print(f"Account: {summary.display_name} ({summary.account})")
        for prop in summary.property_summaries:
            print(f"  Property: {prop.display_name} ({prop.property})")

if __name__ == "__main__":
    list_account_summaries()

```

Key implementation details from the source:

- `AnalyticsAdminServiceClient()` instantiates with zero configuration when ADC is properly set
- `list_account_summaries()` returns a paginated iterator of `AccountSummary` protobuf messages
- Each `AccountSummary` contains nested `property_summaries` for hierarchical navigation

## Admin API Use Cases and Capabilities

The "Admin API Use Cases" section in [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md) (lines 58-76) enumerates every supported operation category:

- **Account lifecycle**: Create accounts, configure data-sharing settings, manage user links
- **Property management**: Create properties, update data-retention windows, configure attribution models
- **Data streams**: Web, iOS, and Android stream creation and measurement ID allocation
- **Custom definitions**: Custom dimensions and metrics with scope configuration
- **Conversion events**: Mark events as conversions, modify counting methods
- **Measurement protocol**: Generate and rotate API secrets for server-to-server tracking
- **Cross-product links**: Firebase, Google Ads, Display & Video 360, Campaign Manager integrations

## Version Selection: v1beta vs. v1alpha

The Admin API exposes two versions with distinct stability guarantees. The skill explicitly highlights this distinction to prevent feature availability errors.

| Version | Stability | Exclusive Capabilities |
|---------|-----------|------------------------|
| **v1beta** | Stable | Core account/property/stream operations, custom definitions, conversion events |
| **v1alpha** | Preview | Roll-up properties, sub-properties, ad-network links, enhanced measurement controls |

When implementing **managing Google Analytics properties with the Admin API** for production systems, pin to `v1beta` unless you explicitly require alpha features. The Python client library defaults to `v1beta`; override via:

```python
from google.analytics.admin_v1alpha import AnalyticsAdminServiceClient  # alpha explicitly

```

This versioning guidance appears in [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md) lines 78-96 and prevents common integration failures when developers attempt to access preview features through stable endpoints.

## Skill Metadata and Classification

The skill's `metadata.category: GoogleAnalytics` classification (per [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md)) positions it within the broader Google Analytics skill set. This categorization enables automated discovery in tooling that consumes the google/skills repository.

The three-stage pattern—**API enablement → Authentication → Client-library interaction**—repeats across all Google Cloud API skills in the repository, making this Admin API skill a transferable template for other Google Cloud integrations.

## Summary

- **Enable the service first**: Run `gcloud services enable analyticsadmin.googleapis.com` before any code execution
- **Use ADC exclusively**: Configure `GOOGLE_APPLICATION_CREDENTIALS` or `gcloud auth application-default login` with appropriate scopes
- **Match client version to feature needs**: Use `v1beta` for stable operations, `v1alpha` only for roll-up properties or sub-properties
- **Start with `list_account_summaries()`**: This read-only operation validates your entire authentication and authorization chain

## Frequently Asked Questions

### How do I handle permissions errors when calling the Admin API?

Permissions errors typically indicate missing OAuth scopes or insufficient IAM roles. Verify your ADC token includes `analytics.readonly` or `analytics.edit` as needed. For service accounts, grant the "Analytics Account Admin" or "Analytics Property Admin" roles in the Google Analytics account settings, not just Cloud IAM.

### Can I use the Admin API with Google Analytics 4 properties only?

Yes. The Admin API exclusively supports **Google Analytics 4** properties. Universal Analytics (UA) properties require the Management API (v3), which has separate authentication and endpoint patterns. The skill's [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md) explicitly targets GA4 infrastructure.

### What's the difference between the Admin API and the Data API?

The **Admin API** (covered here) manages account structure, properties, streams, and configuration. The **Data API** (separate service) queries report data from GA4 properties. They share ADC authentication but require different client libraries and service endpoints—enable `analyticsdata.googleapis.com` for reporting operations.

### How do I upgrade from v1alpha to v1beta when features stabilize?

Monitor the [Google Analytics Admin API release notes](https://developers.google.com/analytics/devguides/config/admin/v1) for promotion announcements. When a feature graduates, update your client library import from `google.analytics.admin_v1alpha` to `google.analytics.admin` (or `google.analytics.admin_v1beta` for explicit versioning). No code changes are required for method signatures that remain identical across versions.