GA4 API: How to Pull Your Data Programmatically
By Emily Redmond, Data Analyst at Emilytics · April 2026
TL;DR: GA4's Reporting API lets you pull data programmatically. Build automated reports, dashboards, or integrations without manual exports.
Exporting GA4 reports by hand is tedious. The API automates it. Pull data directly into spreadsheets, custom dashboards, or your data warehouse.
What Is the GA4 API?
The GA4 Reporting API lets you request GA4 data programmatically. Instead of:
- Open GA4
- Click through menus
- Export CSV
- Paste into spreadsheet
You write code (or use a tool) to:
- Request data from GA4 API
- Get the results automatically
- Update your dashboard/spreadsheet daily
This is useful for:
- Automated daily reports: Emails sent to stakeholders every morning
- Custom dashboards: Data in Sheets, Looker, Tableau
- Integration with other tools: Send GA4 data to CRM, data warehouse, etc.
- Data analysis: Pull raw data into Python/R for statistical analysis
Prerequisites
- GA4 property with data collection
- Google Cloud project (free)
- Service account with GA4 API access
- Basic programming knowledge (or use a pre-built tool like Data Studio)
Getting Started: Service Account Setup
Step 1: Create a Google Cloud Project
- Go to console.cloud.google.com
- Create a new project (top left, click project dropdown)
- Name it (e.g., "GA4 API Integration")
- Create
Step 2: Enable the GA4 Reporting API
- In Google Cloud, go to APIs & Services → Library
- Search for "Google Analytics Reporting API"
- Click it
- Click Enable
Step 3: Create a Service Account
- Go to APIs & Services → Credentials
- Click Create Credentials → Service Account
- Fill in the account name (e.g., "ga4-api-reader")
- Create
Step 4: Generate a Key
- Click the service account you created
- Go to Keys tab
- Click Add Key → Create new key → JSON
- Download the JSON file (keep it safe—it's your credentials)
Step 5: Grant GA4 Access
- Go to your GA4 property
- Go to Admin → Account access management
- Click Grant Access
- Invite the service account email (from the JSON file, looks like
[email protected]) - Give it "Editor" or "Analyst" role
- Grant
GA4 now trusts the service account.
Using the API: Code Example
Python Example
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import RunReportRequest
# Initialize client with your service account JSON
client = BetaAnalyticsDataClient()
# Your GA4 property ID (numeric, from Admin → Property settings)
property_id = "1234567890"
# Define the report
request = RunReportRequest(
property=f"properties/{property_id}",
date_ranges=[{"start_date": "2024-01-01", "end_date": "2024-01-31"}],
dimensions=[{"name": "date"}, {"name": "country"}],
metrics=[{"name": "activeUsers"}, {"name": "conversions"}],
)
# Run the report
response = client.run_report(request)
# Print results
for row in response.rows:
print(row.dimension_values, row.metric_values)
This pulls daily active users and conversions by country for January 2024.
Google Sheets Example (No Code)
If you don't want to code, use the Google Analytics Connector for Sheets:
- Open Google Sheets
- Data → Data connectors
- Search for "Google Analytics"
- Click Google Analytics Connector
- Authorize and connect your GA4 property
- Choose dimensions and metrics
- Sheets automatically pulls data and updates daily
No API setup needed.
Common API Queries
Daily Conversions
Date, Conversions
Property: [your GA4 property]
Dimensions: date
Metrics: conversions
Date range: Last 30 days
Revenue by Traffic Source
Source/Medium, Revenue
Dimensions: source/medium
Metrics: revenue
Date range: Last 7 days
Page Performance
Page, Users, Conversions, Conversion Rate
Dimensions: pagePath
Metrics: activeUsers, conversions
Date range: Last 30 days
API Limits
- Free tier: 10,000 requests/day (usually enough)
- Reporting: Up to 100,000 dimensions per request
- Rate limiting: 1,000 concurrent requests
For most businesses, you won't hit these limits.
Tools That Use GA4 API Internally
You don't always need to code. These tools use the API and provide UI:
- Google Data Studio: Free, visual dashboards
- Google Sheets Connector: Free, integrates with Sheets
- Looker Studio: Free/paid, advanced analytics
- Supermetrics: Paid, pulls GA4 into Sheets, Excel, Email
- Automation tools: Zapier, Make, IFTTT can trigger GA4 API queries
For non-technical users, start with Data Studio or Sheets Connector.
Frequently Asked Questions
Q: Is the GA4 API free? A: Yes, for reasonable usage (most teams stay well under the daily limit).
Q: Do I need a service account for the API? A: Yes, for automated access. Alternatively, you can use OAuth flow (user grants permission).
Q: What's the difference between GA4 API and BigQuery? A: GA4 API is good for quick queries and automation. BigQuery is better for large-scale data analysis and historical data.
Q: Can I pull real-time data? A: GA4 API has limited real-time support. For real-time data, use the Real-Time API or GA4's Real-Time report.
Q: How often should I query the API? A: Daily is typical for most dashboards. Real-time queries can happen multiple times/hour, but watch for rate limits.
The Bottom Line
GA4 API is powerful for automation. Instead of manual exports, pull data on demand. Build dashboards that auto-update. Send daily reports via email.
For most teams, Google Sheets Connector or Data Studio is enough. No coding required.
If you need more control, learn the API. It's well-documented and Python/JavaScript examples are easy to find.
Emily Redmond is a data analyst at Emilytics — the AI analytics agent that watches your GA4, Search Console, and Bing data around the clock so you never miss what matters. 8 years of experience helping founders and growth teams turn data noise into clear decisions. Say hi →