1. Home
  2. Google Analytics
  3. Use GA4 with Other Tools ...
  4. Learn About the Google Analytics APIs

Learn About the Google Analytics APIs

Objective

This SOP explains the core Google Analytics APIs, Admin API, Data API, Measurement Protocol, and User Deletion API, and how they can be used to automate reporting, enhance property configuration, and send or delete custom data. These APIs help teams scale analytics operations and gain real-time, flexible access to insights.

Overview

This SOP covers:

  1. What each Google Analytics API does
  2. Key use cases and benefits
  3. Authentication setup via Google Cloud
  4. Real-world examples from Jason’s retail business
  5. API vs BigQuery comparisons for different data goals

Why Use Google Analytics APIs?

Using the APIs enables:

  • Automation of time-consuming tasks
  • Real-time access to reporting data
  • Integration with business systems (e.g., CRMs, BI tools)
  • Control over GA4 configurations across properties
  • Custom data collection from offline or unconventional sources
  • Compliance with privacy by processing user deletions

Meet Jason – A Real-World API Use Case

Jason operates a growing sneaker business with:

  • Online and in-store sales
  • Multiple regional marketing teams
  • A desire to unify data and automate account management

Jason’s team uses the Google Analytics APIs to:

  • Streamline property setup
  • Access real-time reports
  • Integrate CRM and offline data
  • Comply with data deletion requests

The Admin API

The Admin API allows you to configure and manage GA4 properties programmatically.

Use cases:

  • Set conversion events, filters, Google Signals, and custom dimensions
  • Automate the creation and updates of properties and accounts
  • Access change history or access logs (GA360)

Jason’s team uses Admin API to automate event setup and track Analytics usage by staff.

The Data API

The Data API retrieves raw report data from your GA4 properties—ideal for custom dashboards and applications.

Use cases:

  • Build real-time dashboards
  • Automate multi-region reports
  • Query funnel steps, event counts, or user segments

Example queries:

  • “How many pageviews for top 10 pages in 28 days?”
  • “How many users from the US today?”
  • “How many app users in the last 30 minutes?”

Jason integrates GA data into a third-party BI tool using the Data API.

The Measurement Protocol

Measurement Protocol allows developers to send custom or offline data directly to GA4 using HTTP requests.

Use cases:

  • Record offline conversions
  • Send events from kiosks, gaming consoles, or CRMs
  • Measure server-side events
  • Integrate with point-of-sale systems

Jason’s team sends in-store purchase events using Measurement Protocol for unified tracking.

The User Deletion API

This API processes deletions of data linked to a specific user ID, client ID, or app instance ID.

Use cases:

  • Delete user data upon customer request (e.g., GDPR)
  • Programmatically handle bulk data deletion
  • Maintain privacy compliance

Jason’s support team uses this API to fulfill customer deletion requests efficiently.

Step 1: Set Up API Access via Google Cloud

To use the Admin or Data APIs:

  1. Visit the Google Cloud Console
  2. Create or select a project
  3. Enable the Google Analytics Admin API and/or Data API
  4. Configure OAuth 2.0 credentials
  5. Use these credentials in your app or script to authenticate API calls

Step 2: Use APIs Together with BigQuery

ToolBest For
Data APIReal-time reports, embedded dashboards, lightweight queries
BigQueryHistorical data, machine learning, modeling, large joins

Combined Use Case:

Export GA4 data to BigQuery for long-term storage and heavy processing, then use Data API for real-time metrics or lightweight app integrations.

Jason stores sales data in BigQuery, builds dashboards with Looker Studio, and pulls real-time figures via the Data API.

Common Use Cases at a Glance

APIPurposeJason’s Use Case
Admin APIManage GA4 config: conversions, dimensions, integrationsSet up new property configurations for each store region
Data APIRetrieve GA report dataAutomate weekly funnel and app engagement reports
Measurement ProtocolSend events directly to GAUpload CRM-based offline purchases to GA
User Deletion APIDelete user data for complianceRemove data of users who requested account deletion

Step 3: Visualise API Data with Looker Studio

  • Connect Looker Studio to GA via Data API
  • Use custom fields from your GA4 property
  • Note: Data will match GA reports, but not Explorations

For setup help, see: Looker Studio → Connect to GA

How can we help?