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:
- What each Google Analytics API does
- Key use cases and benefits
- Authentication setup via Google Cloud
- Real-world examples from Jason’s retail business
- 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:
- Visit the Google Cloud Console
- Create or select a project
- Enable the Google Analytics Admin API and/or Data API
- Configure OAuth 2.0 credentials
- Use these credentials in your app or script to authenticate API calls
Step 2: Use APIs Together with BigQuery
| Tool | Best For |
| Data API | Real-time reports, embedded dashboards, lightweight queries |
| BigQuery | Historical 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
| API | Purpose | Jason’s Use Case |
| Admin API | Manage GA4 config: conversions, dimensions, integrations | Set up new property configurations for each store region |
| Data API | Retrieve GA report data | Automate weekly funnel and app engagement reports |
| Measurement Protocol | Send events directly to GA | Upload CRM-based offline purchases to GA |
| User Deletion API | Delete user data for compliance | Remove 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