A Google Analytics API integration reads your GA4 figures through Google’s Data API and puts them inside a system you already run. The usual reason is that someone is logging into GA4 every week to export the same CSV.
What This Is
GA4 has three ways to get data out of it, and the API is only the right one some of the time.
Looker Studio connects to GA4 with no code at all. If what you want is a dashboard your team opens in a browser, start there, and you probably don’t need us.
The BigQuery export sends raw event data to Google’s data warehouse. It suits analysts who want every event and will write SQL against it. Standard properties are limited to 1 million events a day on the daily export, and the BigQuery storage and queries are billed by Google once you go past the free sandbox.
The Data API answers report-shaped questions (sessions by landing page last week, key events by channel this month) and returns the result to your own code. That’s what you want when the figures have to sit inside another system: next to a client’s invoices in a portal, on a contact’s record in the CRM, or in a monthly PDF that also needs numbers from somewhere else.
We build the third kind. The integration authenticates with Google, runs the reports on a schedule, turns the response into your own data format and stores it, so the rest of your application never has to deal with GA4’s response structure.
What the GA4 Data API Allows
These figures come from Google’s developer documentation, and we check them again at the start of each project because Google revises them.
- Access is per property. For a server-side integration we use a Google Cloud service account and add its email address to the GA4 property as a user with the Viewer role. Viewer is enough to read reports and can’t change anything. If you’re building a product where each customer connects their own GA4, they sign in with Google instead and grant read-only access.
- Quotas are counted in tokens. A standard property gets 200,000 tokens a day and 40,000 an hour, with 14,000 an hour for any one Google Cloud project against that property, and 10 requests running at once. Analytics 360 properties get ten times those token budgets and 50 concurrent requests. Most requests cost 10 tokens or fewer, but long date ranges, many dimensions and high-cardinality fields such as page path cost more. The API will report what each call cost, so we log it and can see a quota problem coming before it stops a report.
- Batching helps. One
batchRunReportscall can carry up to 5 reports, which matters when you’re pulling the same set of figures for dozens of properties every night. - Yesterday’s data isn’t final first thing. Google gives typical processing times of 2 to 6 hours for intraday data and about 12 hours for daily data on standard properties. A report that runs at 1am and treats yesterday as complete will show numbers that change later. We schedule pulls to allow for that and re-pull the last few days so late-processed data replaces the early figures.
- Some data is withheld. Where Google signals or demographic dimensions are involved, GA4 can apply thresholds and hold back rows to protect user privacy, and those requests have their own hourly limit. If a report depends on age or gender breakdowns, we find out early whether the property returns them at all.
When You Need This
The common trigger is a person spending a morning a week, or a few days a month, copying GA4 figures into something else. Agencies doing it for many clients feel this first, because the time scales with the client list.
The second trigger is combining sources. GA4 can’t tell you cost per enquiry without ad spend, or revenue per visit without sales data from your own systems. Joining those by hand in a spreadsheet each month is where the errors creep in. Our Google Ads API integration work is often built alongside this for that reason.
If you need one dashboard for internal use and nothing else, Looker Studio is cheaper and quicker than anything we would build.
How We Work
We start with the questions the report has to answer, not the list of metrics GA4 offers. Each one becomes a named query: the dimensions, metrics, date range and filters, plus where the answer goes. Pulling everything and deciding later burns quota on data no report uses.
The build is usually Laravel with scheduled jobs. Each pull is idempotent, so running it twice for the same date replaces the figures rather than duplicating them. Responses are stored in your database with the date they were pulled, which lets us re-pull recent days and lets you see when a number changed. Failed calls retry after a delay. A quota error pauses the run until the hourly allowance resets. If a credential expires or someone removes the service account from the property, the system sends an alert and holds the report back.
We use the same setup ourselves: our own site’s analytics are read through the Data API by a service account with Viewer access, and those figures go into our weekly reporting without anyone opening GA4. For a legal publisher we built a reporting system that pulls GA4 and Search Console figures into reports for its advertisers and members, which their team reviews and approves before sending.
If the end result is a scheduled report rather than data inside another system, our GA4 reporting automation page covers that case in more detail.
What You Get
- A written query map: each question, the GA4 query that answers it, and where the result goes
- Service account or per-user Google authentication, with read-only access only
- Scheduled pulls that allow for GA4’s processing delay and refresh recent days
- Stored history in your own database, so period comparisons don’t need fresh API calls
- Quota logging per call, with pulls that pause rather than fail when a limit is close
- Alerts when credentials expire or a property stops returning data
- Multi-property support if you report on more than one site or client
Technologies We Use
The GA4 Data API (runReport, batchRunReports and, where live figures are needed, runRealtimeReport) with the read-only analytics scope, authenticated through a Google Cloud service account or Google sign-in. On our side, Laravel with queued and scheduled jobs and PostgreSQL or MySQL for the stored figures. The API integrations overview lists the other platforms we connect.
Related Systems
Analytics figures usually end up in a reporting dashboard that puts web traffic beside sales and ad spend, or a client portal where each client sees only their own figures. The wider service is described on our API integrations page.
Tell Us Where the Numbers Should Go
Send us the GA4 properties involved, the report or system the figures should appear in, and what else needs to sit beside them. We’ll tell you whether the API is the right route or whether Looker Studio or the BigQuery export would serve you better. Start the conversation here.