Google Analytics 4 source

Sync data from Google Analytics 4 to your warehouse destination via RudderStack.

Google Analytics 4 is an analytics service that enables you to measure traffic and engagement across your websites and apps.

This document guides you in setting up Google Analytics 4 as a source in RudderStack. Once configured, RudderStack automatically ingests your Google Analytics 4 data and routes it to your specified data warehouse destination.

warning
All the Cloud Extract sources support sending data only to a data warehouse destination.

Getting started

To set up Google Analytics 4 as a source in RudderStack, follow these steps:

  1. Log into your RudderStack dashboard.
  2. Go to Sources > New source > Cloud Extract and select Google Analytics 4 from the list of sources.
  3. Assign a name to your source and click Continue.

Connection settings

Next, configure the following dashboard settings:

  • Credentials: From the dropdown, select the authentication mechanism for RudderStack to connect to the Google Analytics 4 API.
    • Authenticate via Google (OAuth): To authenticate via OAuth, click the Sign in with Google button, select your Google account, and give RudderStack the required permissions.
    • Service Account Key Authentication: Enter your service account JSON credentials in the Service Account Information field.
Google Analytics 4 authentication

The other settings are as follows:

Google Analytics 4 dashboard settings
  • Property ID: Specify the Google Analytics 4 property identifier whose events are tracked.
  • Date Range Start Date: Choose the start date from which you want RudderStack to ingest the Google Analytics 4 data. RudderStack will not replicate any data before this date.
  • Custom Reports: Use this setting to sync your custom Google Analytics 4 reports. To add a custom report, click Add Report and specify the Report Name, Metrics, and Dimensions:
Google Analytics 4 custom reports
info
You can sync multiple reports, and edit or delete a custom report.
  • Data request time increment in days: Enter the number of days after which RudderStack requests data from the Google Analytics 4 API. The minimum and maximum allowed values for this field are 1 and 364 respectively.
info
It is highly recommended to set this value to 1. A higher value will lead to faster syncs, but it is more likely to apply sampling on your data, causing potential inaccuracies in the results.

Destination settings

The following settings specify how RudderStack sends the data ingested from Google Analytics 4 to the connected warehouse destination:

  • Table prefix: RudderStack uses this prefix to create a table in your data warehouse and loads all your Google Analytics 4 data into it.
warning
Note that RudderStack does not add special characters like - or _ to the prefix by default. Hence, you need to specify it while setting the prefix.
  • Schedule Settings: RudderStack gives you three options to ingest the data from Google Analytics 4:
    • Basic: Runs the syncs at the specified time interval.
    • CRON: Runs the syncs based on the user-defined CRON expression.
    • Manual: You are required to run the syncs manually.
info
For more information on the schedule types, refer to the Common Settings guide.

Selecting the data to import

You can choose the predefined Google Analytics 4 reports from which you want to ingest the data by selecting them in this window:

Selecting the data to import
info
Any custom reports configured using the Custom Reports dashboard setting will also be shown here.

The below table mentions the sync types supported by the Google Analytics 4 resources while syncing data to your warehouse destination:

ResourceSync typePrimary key
daily_active_usersIncrementaluuid
devicesIncrementaluuid
four_weekly_active_usersIncrementaluuid
locationsIncrementaluuid
pagesIncrementaluuid
traffic_sourcesIncrementaluuid
website_overviewIncrementaluuid
weekly_active_usersIncrementaluuid

For syncing all reports, RudderStack uses the analyticsdata.googleapis.com/v1beta/{property_id}/runReport API.

warning
This source only supports Incremental reports with date as a required dimension.
info
For more information on the Incremental sync mode, refer to the Common Settings guide.

Google Analytics 4 is now configured as a source. RudderStack will start ingesting data from Google Analytics 4 as per your specified schedule and frequency.

You can further connect this source to your data warehouse by clicking the Add Destination button:

Adding a destination
info
Use the Use Existing Destination option if you have an already-configured data warehouse destination in RudderStack. To configure a data warehouse destination from scratch, select the Create New Destination button.

FAQ

Is it possible to have multiple Cloud Extract sources writing to the same schema?

Yes, it is.

RudderStack associates a table prefix for every Cloud Extract source writing to a warehouse schema. This way, multiple Cloud Extract sources can write to the same schema with different table prefixes.

How does RudderStack count the events for Cloud Extract sources?

RudderStack counts the number of records returned by the source APIs when queried during each sync. It considers each record as an event.

How does RudderStack set the table name for the data sent via Cloud Extract sources?

RudderStack sets the table name for the resource you are syncing to the warehouse by adding rudder_ to the Table prefix you set while configuring your Cloud Extract source in the dashboard.

Cloud Extract table prefix

For example, if you set test_ as the Table prefix in the dashboard, RudderStack sets the table name as test_rudder_<resource_name>, where <resource_name> is the name of the resource you are syncing (for example, contacts, messages, etc.).

warning
Note that RudderStack does not add the character _ to the prefix by default. Hence, you need to specify it while setting the prefix.

Why am I getting a 403 Client Error while setting up the Google Analytics 4 source?

You must assign the following permissions in Google Analytics 4 to set it up as an Extract source successfully:

const scope_google_analytics = [
  'https://www.googleapis.com/auth/userinfo.profile',
  'https://www.googleapis.com/auth/userinfo.email',
  'https://www.googleapis.com/auth/analytics.readonly',
];

Questions? Contact us by email or on Slack