Overview
Google Analytics 4 (GA4) is the current Google Analytics platform — the event-based analytics system that replaced Universal Analytics in 2023 and is now the standard for web and app analytics. GA4 tracks user behaviour through a flexible event model where every interaction — page views, clicks, form submissions, purchases, custom events — is recorded as an event with associated parameters. The event data flows from websites and apps into GA4's reporting infrastructure, where it is available for analysis through GA4's reporting interface and, more importantly for custom analytics integrations, through the GA4 Data API and BigQuery export.
Google Analytics integration in the context of custom software development spans several distinct use cases. Sending data to GA4 — implementing the GA4 tracking code, configuring custom events, using the Measurement Protocol to send server-side events, and using the Admin API to manage GA4 properties and data streams programmatically. Reading data from GA4 — using the GA4 Data API to query analytics data for custom dashboards, reports, and analytical applications that need GA4 metrics and dimensions beyond what GA4's native reporting interface provides. And connecting GA4 data to downstream data infrastructure — the BigQuery export that makes GA4 raw event data available for SQL analysis, machine learning, and the custom analytics pipelines that GA4's standard reports cannot support.
For marketing agencies, e-commerce businesses, and digital product teams, GA4 integration is often a component of the broader analytics and reporting infrastructure. The client reporting dashboard that queries GA4 for traffic and conversion data. The e-commerce analytics system that combines GA4 behavioural data with CRM and order management data for unified customer analytics. The marketing attribution system that uses GA4 event data to measure campaign performance. The custom funnel analysis that combines GA4 data with server-side event data that GA4 tracking did not capture.
We build Google Analytics integrations for marketing agencies, e-commerce businesses, SaaS products, and analytics teams that need to connect their systems to GA4 for data collection, data retrieval, or both.
What Google Analytics Integration Covers
GA4 tracking implementation. The client-side and server-side event tracking that sends data to GA4.
Google Tag Manager implementation: the preferred method for deploying GA4 tracking to websites without direct code modification. The GA4 Configuration tag in GTM that initialises the GA4 tracking code with the measurement ID. The event tags that fire on specific triggers — page views, form submissions, button clicks, e-commerce events — and send the corresponding events to GA4 with configured parameters.
gtag.js direct implementation: the gtag('event', ...) function calls in website JavaScript that send custom events to GA4 when GTM is not available or when direct code control is preferred. The gtag('config', ...) call that initialises GA4 with the measurement ID and configuration options. The dataLayer push that GTM-based implementations use to pass data from the application to the GTM tags.
E-commerce event tracking: the GA4 e-commerce events — view_item, add_to_cart, begin_checkout, purchase, refund — with their required and recommended parameters. The purchase event with the transaction_id, value, currency, and the items array that contains product-level data (item ID, name, category, price, quantity). The complete e-commerce tracking implementation that populates GA4's e-commerce reports.
Custom event design: defining the custom events and parameters that capture the application-specific user behaviours that GA4's automatically collected events do not cover. The event naming conventions (snake_case names, maximum 40 characters) and the parameter naming conventions that GA4 enforces. The custom dimensions and metrics in GA4 that expose event parameters for use in reports and API queries.
Enhanced measurement: GA4's automatic event collection for scrolls, outbound clicks, site search, video engagement, and file downloads. The enhanced measurement configuration that enables these events without additional code.
Measurement Protocol — server-side event sending. The GA4 Measurement Protocol for sending events to GA4 from server-side code — for events that occur outside the browser, for supplementing client-side data with server-side context, or for server-side conversion tracking.
Measurement Protocol endpoint: the POST https://www.google-analytics.com/mp/collect?measurement_id={id}&api_secret={secret} endpoint that accepts GA4 event data in JSON format. The request body with the client_id (the GA4 client identifier for the user), the user_id (the authenticated user identifier for cross-device tracking), the timestamp_micros (the event timestamp in microseconds since Unix epoch for historical event backfilling), and the events array.
Server-side purchase events: the Measurement Protocol purchase event that records conversions server-side — the authoritative conversion data from the server's order management system rather than the client-side event that may be blocked by ad blockers or lost due to client-side errors. The server-side purchase event that ensures conversion data in GA4 matches the actual order data in the business's systems.
Client ID management: the GA4 client ID is the anonymous identifier that GA4 uses to associate events with a specific browser session. Retrieving the client ID from the _ga cookie for server-side events that need to be associated with the same user session as client-side events. The cookie value parsing that extracts the client ID from the GA1.{hash}.{client_id} cookie format.
Validation endpoint: the POST https://www.google-analytics.com/debug/mp/collect endpoint that validates Measurement Protocol event payloads without actually recording the events — the testing tool that confirms the event format is correct before sending real data.
GA4 Data API — querying analytics data. The REST API for programmatic access to GA4 analytics reports — the interface for building custom dashboards, automated reports, and analytics applications that consume GA4 data.
Authentication: the GA4 Data API uses Google's OAuth 2.0 / service account authentication. The service account JSON key file with the credentials that grant read access to GA4 property data. The https://www.googleapis.com/auth/analytics.readonly scope for read-only access. The service account email address added to the GA4 property with Viewer permissions.
Core reporting: the POST https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}:runReport endpoint for standard analytics reports. The request body with the dimensions array (the dimensions to group by — sessionDefaultChannelGroup, country, deviceCategory, pagePath, eventName), the metrics array (the metrics to measure — sessions, activeUsers, newUsers, screenPageViews, conversions, purchaseRevenue), the dateRanges array (one or two date ranges for comparison), and the optional dimensionFilter and metricFilter for conditional results.
Dimension and metric reference: GA4's dimension and metric catalogue with the API names that the Data API uses — sessions (not ga:sessions as in Universal Analytics), activeUsers, newUsers, eventCount, conversions. The dimension API names — sessionDefaultChannelGroup, sessionSource, sessionMedium, pagePath, landingPage, country, city, deviceCategory, operatingSystem. The custom dimension API names for properties with registered custom dimensions.
Pagination: the limit and offset parameters for paginating large result sets. The rowCount in the response that indicates the total number of rows matching the query — used to calculate the number of pages required and to iterate through all results.
Real-time reporting: the runRealtimeReport endpoint for real-time data — active users in the last 30 minutes, events firing in real time. The real-time API that powers live dashboard widgets showing current site activity.
Funnel exploration: the runFunnelReport endpoint for multi-step funnel analysis — the conversion funnel that measures how users progress through a defined sequence of steps. The funnel report that GA4's standard interface provides but that the Data API makes accessible programmatically for custom funnel dashboards.
GA4 Admin API — property management. The GA4 Admin API for programmatically managing GA4 properties, data streams, custom dimensions, and audiences.
Property management: the GET https://analyticsadmin.googleapis.com/v1beta/properties/{property} endpoint for reading property configuration. The properties.list endpoint for listing all GA4 properties accessible to the service account — used by analytics platforms that manage multiple GA4 properties.
Custom dimensions and metrics: the customDimensions.create endpoint for registering event parameters as custom dimensions in GA4 — making them available in reports and the Data API. The custom dimension configuration with the parameter name, the display name, the scope (EVENT or USER), and the description.
Data streams: the dataStreams.list endpoint for listing the web, iOS, and Android data streams configured for a GA4 property. The stream configuration including the measurement ID and the enhanced measurement settings.
Audience creation: the audiences.create endpoint for programmatically creating GA4 audiences — the audience definitions for remarketing, for analysis, and for the audiences that Google Ads uses for targeting.
BigQuery export and data pipeline. The GA4 BigQuery export for raw event data analysis.
BigQuery export setup: the GA4 BigQuery link configuration that exports raw GA4 event data to BigQuery daily (standard export) or in real-time streaming (streaming export for GA4 360). The BigQuery dataset structure — a date-sharded table per day (events_YYYYMMDD) and an intraday table (events_intraday_YYYYMMDD) for streaming export.
BigQuery schema: the GA4 event schema in BigQuery with the event_date, event_timestamp, event_name, event_params (a repeated record with key-value pairs for event parameters), user_properties (user-scoped properties), user_id, user_pseudo_id (the client ID), device, geo, traffic_source, session_id, and the other fields that GA4 records for each event.
SQL analysis: the BigQuery SQL queries that extract value from the GA4 event data — unnesting the event_params array to access specific parameter values, sessionising event streams, computing funnel conversion rates, joining GA4 user data with CRM data using user_id, and the other analyses that BigQuery's SQL engine enables on raw GA4 data.
Data pipeline integration: the ETL pipeline that processes GA4 BigQuery export data — transforming the raw event data into the aggregated, joined datasets that custom analytics applications consume. The scheduled query or Dataflow pipeline that runs after the daily export completes and updates the downstream analytical tables.
Consent mode and privacy. GA4 operation in compliance with GDPR and the Dutch cookie law requirements.
Consent mode v2: the Google Consent Mode implementation that adjusts GA4's data collection behaviour based on the user's consent choices. The gtag('consent', 'default', {...}) call that sets the default consent state before the consent banner is shown, and the gtag('consent', 'update', {...}) call that updates consent state after the user makes their choice. The consent parameters — analytics_storage, ad_storage, ad_user_data, ad_personalization — mapped to the relevant consent choices in the consent management platform.
Cookieless measurement: GA4's modelled data for users who decline analytics cookies — Google's machine learning models that estimate conversion rates and traffic patterns for the non-consenting segment. The impact of consent rate on GA4 data completeness and the calibration required for reporting in environments with significant consent refusal rates.
Server-side tagging: the Google Tag Manager server-side container that processes tags on a server rather than in the browser — reducing client-side JavaScript execution, improving page performance, improving data quality by reducing ad blocker impact, and providing more control over the data sent to GA4.
Client Reporting Applications
For marketing agencies, GA4 is the primary data source for client performance reporting. The GA4 Data API enables automated report generation that replaces manual report compilation.
Multi-property reporting: the analytics platform that manages GA4 data across many client properties — querying multiple GA4 property IDs, normalising the results into a consistent format, and presenting comparative or aggregated data across clients.
Scheduled report generation: the automated report that runs weekly or monthly, queries the GA4 Data API for the report period's metrics, formats the results into the branded report template, and distributes to clients via email or the client portal.
Custom dashboard development: the React/Next.js dashboard that queries the GA4 Data API directly, displaying the specific metrics and dimensions that the client's marketing team monitors — traffic trends, conversion rates, campaign performance, top pages, geographic breakdown — in a custom UI rather than the generic GA4 interface.
Technologies Used
- GA4 Measurement Protocol — server-side event sending
- GA4 Data API — analytics data querying for custom reports and dashboards
- GA4 Admin API — property management, custom dimension configuration
- Google Tag Manager — client-side GA4 tag deployment and event tracking
- gtag.js — direct GA4 JavaScript implementation
- Google Cloud BigQuery — GA4 raw event data export and SQL analysis
- OAuth 2.0 / Service Accounts — GA4 API authentication
- Python — GA4 Data API client, BigQuery data processing, analytics pipelines
- TypeScript / Node.js — GA4 Data API integration for Node.js backends and reporting tools
- C# / ASP.NET Core — GA4 API integration for .NET reporting applications
- React / Next.js — custom analytics dashboard frontends consuming GA4 Data API
- Google Cloud Dataflow / Scheduled Queries — BigQuery-based GA4 data pipeline
- SQL — BigQuery GA4 event data analysis
GA4 Data Quality Considerations
GA4 data quality in production applications requires attention to several factors that affect the reliability of GA4 as a data source.
Sampling: GA4's standard reports use sampled data when queries cover large date ranges or high-traffic properties. The GA4 Data API returns sampled data when the query exceeds GA4's unsampled data thresholds — the samplingMetadatas field in the API response that indicates the sampling percentage applied. The BigQuery export path that avoids sampling entirely by querying the raw event data directly.
Ad blocker impact: client-side GA4 tracking is blocked by ad blockers and privacy-focused browsers. The server-side tagging and Measurement Protocol approaches that reduce the impact of client-side blocking on data completeness. The data gap between GA4 session counts and server-side session counts that quantifies the ad blocker impact.
Cross-domain tracking: the linker parameter that passes the GA4 client ID across domain boundaries — ensuring that user sessions that span multiple domains (the main site and the payment processor, the landing page and the main website) are tracked as a single session rather than separate sessions with a separate client ID.
Analytics Infrastructure That Serves the Business
GA4 integration that goes beyond the standard implementation — server-side events that ensure conversion data completeness, Data API queries that power custom reporting, BigQuery export pipelines that enable advanced analytics, and the consent mode implementation that keeps data collection compliant with Dutch and EU privacy regulations.