The short version: Yes, Google Analytics has an API, and if you’re on GA4 the one you want is the Google Analytics Data API (the old Reporting API v4 is dead and buried with Universal Analytics). It’s free, it uses OAuth 2.0 or a service account, and it comes with a daily quota of 25,000 core tokens per property, which sounds generous until you build a dashboard that refreshes every hour. I’ve used it to pull traffic data into client spreadsheets for years, and the setup takes about 20 minutes once you know which buttons to press.
The API you probably want (and the one that’s already dead)
Google Analytics has had three different APIs over the past decade, and if you Google this topic you’ll find a pile of old tutorials still pointing at the wrong one. Here’s what’s live in 2026:
- Google Analytics Data API (GA4): this is the current one. It’s what you use to pull reports out of a GA4 property. Live, maintained, the one Google wants you using.
- Universal Analytics Reporting API v4: dead. Google shut off UA data collection in July 2023 and the API stopped serving live data not long after. If a tutorial references view IDs instead of property IDs, it’s talking about this one. Skip it.
- Google Analytics Admin API: this manages the account itself, creating properties, managing data streams, setting up conversion events programmatically. Useful if you’re an agency provisioning dozens of client accounts and don’t want to click through the UI each time.
- Measurement Protocol: this isn’t for pulling data out, it’s for sending data in. You use it to send server-side hits to GA4 from a backend system, a CRM, or an app that can’t fire a normal browser tag.
Four APIs, four different jobs. Most developers asking “does Google Analytics have an API” mean the first one, so that’s what the rest of this post focuses on.
What the GA4 Data API lets you do
In plain terms, it lets you ask GA4 the same questions you’d ask through the web interface, sessions, users, conversions, revenue, page views, broken down by any dimension you like, but you get the answer back as structured JSON instead of a chart you have to screenshot. You can filter by date range, segment by channel, and request up to ten metrics and nine dimensions in a single call.
What it does not do is give you raw, row-level event data. If you want every single click a visitor made with a timestamp, you need BigQuery export, which is a separate (also free, for standard GA4 properties) setup that streams your raw events into a BigQuery table. The Data API gives you aggregated reports, BigQuery export gives you the firehose. People conflate the two constantly and then get frustrated that the API “can’t do what they need.”
Getting it set up: the real steps
I’ll walk through this the way I did it for a client last year, a small ecommerce brand who wanted their weekly sales-traffic numbers dropped straight into a Google Sheet without anyone logging into GA4.
- Create a Google Cloud project. Go to console.cloud.google.com, create a new project, give it a sensible name like “client-ga4-reporting.”
- Enable the Google Analytics Data API. In the Cloud Console’s API library, search for it and hit enable. This takes about 30 seconds and costs nothing.
- Create a service account. Under IAM & Admin, create a service account and generate a JSON key. This key is how your code authenticates without a human logging in each time.
- Add the service account as a user in GA4. This is the step people forget. The service account has its own email address, something like [email protected]. You need to go into GA4 Admin, Property Access Management, and add that email as a Viewer. Skip this and every single call will fail with a permissions error that gives you no useful clue why.
- Install the client library. Google publishes official libraries for Python, Node.js, Java, PHP,.NET, Go and Ruby. For Python it’s a one-line pip install of google-analytics-data.
- Write the request. A basic call asks for a property ID, a date range, and the metrics and dimensions you want. Something like sessions and conversions, broken down by sourceMedium, over the last 28 days.
For that client, the whole thing ran as a scheduled Python script on a small server, pulled the previous week’s numbers every Monday morning, and wrote them into a Google Sheet that fed a Looker Studio dashboard their marketing manager opened. Total build time was about half a day, most of which was me hunting down why my first fifteen calls returned a permission denied error (see step 4, the one I skipped the first time round too).
The quota numbers nobody puts in plain English
Here’s where the API stops being free and easy and starts having real limits. Standard GA4 properties get 25,000 tokens per day and 5 tokens per hour per property for the core method. Each API call costs tokens based on how complex the request is, more dimensions and metrics, longer date ranges, and it costs more tokens. A simple report might cost 1 token. A complicated one with several custom dimensions and a 12-month date range can cost 10 or more.
That 25,000 daily figure sounds huge until you’re running a dashboard that auto-refreshes every 15 minutes for 20 client properties. Do the maths: that’s 96 refreshes a day per property, and if each refresh costs even 5 tokens across a handful of report cards, you’ll burn through your quota by mid-afternoon and start getting throttled with a 429 error. I’ve watched an agency build exactly this setup, get it working beautifully in testing with one property, then roll it out to their full client list and watch half the dashboards go blank by lunchtime. The fix is caching, storing the results somewhere and only hitting the live API on a schedule that respects the quota, not on every page load.
GA4 360 (the paid enterprise tier) gets a much bigger quota, 250,000 tokens a day, but almost nobody reading this is on 360, so plan around the free tier limits from day one, not after you’ve hit them.
What developers build with this
In practice the API shows up in a handful of recurring jobs:
- Client reporting dashboards. Pulling GA4 numbers into a white-label report so an agency doesn’t need to give every client login access to their own GA4 property.
- Alerting. A script that checks conversion rate daily and pings Slack if it drops below a threshold, catching a broken checkout flow before the client notices lost revenue.
- Cross-tool syncing. Feeding traffic data into a CRM so sales can see which leads came from organic search versus paid, which matters a lot if you’re also tracking things like which backlinks are driving referral traffic rather than just sitting in a link report doing nothing.
- Feeding an SEO audit. Pulling landing page performance data programmatically to sit alongside Search Console data when you’re running a full technical SEO audit, since GA4 tells you what happens after the click and Search Console tells you what happened before it.
The uncomfortable bit most guides skip over
Here’s the thing I’ll say plainly that most API tutorials won’t: for the vast majority of small businesses reading this, the API is the wrong answer. Building a custom integration, maintaining a service account, handling token refreshes, debugging quota errors, that’s a genuine engineering job, and it needs upkeep every time Google tweaks the API (which it does, quietly, a few times a year). If what you need is “I want to see last month’s traffic and conversions without logging into five different tools,” Looker Studio connects to GA4 natively with zero code and zero quota management on your end for basic use. I’ve built API integrations for clients who, six months later, admitted a free Looker Studio dashboard would have done 90 percent of the job for none of the maintenance headache.
The API earns its place when you need something Looker Studio can’t do: writing GA4 data into a system that isn’t Google’s own tools, automating alerts, combining GA4 with data from three other platforms in one custom view, or building a product where analytics data is a feature, not a report. If none of that describes your situation, save yourself the service account headaches.
A quick note on API changes and why this stuff shifts under you
Google has form for reshaping its developer tools with short notice, the Universal Analytics sunset being the obvious recent example, and anyone doing serious work with the API needs to treat it as a living target rather than a fixed spec. I keep an eye on this kind of shift through the same channels I use for broader AI and marketing tooling updates, because API and platform changes rarely arrive with much warning and the businesses caught out are always the ones who built something once and never checked back.
This is also, honestly, a decent skill to have on your CV if you’re early in an SEO or marketing career. Being able to say “I’ve pulled GA4 data via the API and automated a client report” is a specific, provable skill, and it’s the kind of detail that gets noticed if you’re trying to apply for remote SEO roles as a beginner and need something concrete to point to beyond “I know how to use Google Analytics.”
Common mistakes I keep seeing
- Forgetting the service account needs GA4 access. Covered above, still the number one support question.
- Requesting too much date range in one call. Break a 12-month pull into monthly chunks; it’s kinder to your quota and easier to debug when something breaks.
- Confusing sampled and unsampled data. High-traffic properties can get thresholding applied to certain dimension combinations for privacy reasons, and the numbers you get back through the API can differ slightly from what you see in the UI. This isn’t a bug, it’s how GA4 protects small user segments.
- Hardcoding the property ID. If you’re building this for more than one client, store property IDs in a config file, not inline in the script, because you will eventually onboard client number six at 4pm on a Friday and not want to touch the code.
None of this replaces understanding what your traffic sources mean once the data lands. I’ve seen more than one dashboard proudly displaying beautifully automated numbers that nobody on the team knew how to interpret, which circles back to something worth saying about how UK SEO and analytics work together in practice: the tooling is only as useful as the person reading the output.
Frequently asked questions
Is the Google Analytics API free to use?
Yes, for standard GA4 properties. You get 25,000 core tokens per property per day and 5 per hour, which covers most small to mid-size reporting needs; only GA4 360, the paid enterprise tier, gets a bigger quota of 250,000 tokens a day.
Can I still use the Universal Analytics API in 2026?
No. Universal Analytics stopped processing new data in mid-2023 and its Reporting API v4 no longer serves live results. Any project referencing UA view IDs needs migrating to the GA4 Data API using property IDs instead.
Do I need to know how to code to use the Google Analytics API?
Yes, in a practical sense. Google provides official client libraries for Python, Node.js, Java, PHP,.NET, Go and Ruby, but you still need to write and host a script, handle authentication, and manage errors. If you don’t code, a no-code connection through Looker Studio will cover most reporting needs without touching the API directly.
What’s the difference between the GA4 Data API and BigQuery export?
The Data API returns aggregated reports, sessions, users, conversions grouped by dimensions you choose. BigQuery export streams raw, row-level event data into a BigQuery table, giving you access to every individual event rather than summarised totals. Use the Data API for dashboards and reporting, use BigQuery export when you need granular, event-level analysis.