Set up Google Analytics 4 as a destination in RudderStack.
RudderStack supports sending event data to Google Analytics 4 via the following connection modes:
Connection Mode
Web
Mobile
Server
Device Mode
Supported
-
-
Cloud Mode
Supported
Supported
Supported
In a web device mode integration, that is, using JavaScript SDK as a source, RudderStack loads the Google Analytics 4 native SDK from https://www.googletagmanager.com/ domain. Based on your website’s content security policy, you might need to allowlist this domain to load the Google Analytics 4 SDK successfully.
Once you have confirmed that the source platform supports sending events to Google Analytics 4, follow these steps:
Select an existing source from the displayed ones or set up a new source to connect to Google Analytics 4 and click Continue.
Connection settings
To successfully configure Google Analytics 4 as a destination, configure the following settings:
Name: Assign a name to your destination.
API Secret: Enter the API Secret generated through the Google Analytics dashboard. It can be created in the Google Analytics dashboard under Admin > Data Streams > Choose your stream > Measurement Protocol > Create.
Client Type: Select the client type as gtag or Firebase from the dropdown:
gtag - Supported for both cloud and device mode. If you select gtag, enter the following:
Measurement ID: Enter the Measurement ID which is the identifier for a data stream. It can be found in the Google Analytics dashboard under Admin > Data Streams > Choose your stream > Measurement ID.
Firebase - Supported only for cloud mode. If you select Firebase, enter the following:
Firebase App Id: Enter the Firebase App ID which is the identifier for Firebase app. It can be found in the Firebase dashboard under Project Settings > General.
Refer to the FAQ section for more information on how to obtain the API secret, Measurement ID, and Firebase App ID.
Connection mode
Choose how to connect Google Analytics 4 to your source(s) by selecting from the cloud, device, or hybrid modes.
Further, click Continue and Configure your destination.
Configuration settings
In the Configuration tab of your destination, you can configure the below-mentioned cloud and device mode settings:
Cloud mode
Enable debug mode: Enable this setting to check the validation responses in the Live Events tab. Debug mode is supported via the validation server endpoint. However, as per the GA4 documentation, any responses sent to the validation server will not show up in the reports.
Device mode
Choose how to capture pageviews: Select RudderStack JS SDK or gtag Automated Capture from the dropdown depending on whether you want to send the page view events through the RudderStack JS SDK, or through automatic collection on each page load using GA4 Enhanced Measurement (gtag) respectively. Refer to the GA4 documentation for more information.
Include URL and Search as Page View properties: Enable this setting to send the following properties along with any other custom property to the page call of the RudderStack SDK:
url
search
Google Analytics 4 has a limit on the number of unique properties per event name. The default page_view event supports the properties mentioned in the Automatically collected events in Google Analytics 4 guide.
Add send_to parameter in gtag event call: Enable this setting to send an event only to the specific Google Analytics 4 property whose Measurement Id you have specified above. When enabled, a sample event to Google Analytics 4 looks as shown:
gtag('event','view_video',{'send_to':'<property_id>'});// where <property_id> is the measurement id of the GA4 data stream.
Choose if you want to turn on events filtering: This option is applicable only if you’re sending events to Google Analytics 4 via web device mode. Refer to the Client-side Event Filtering guide for more information.
Cookie category name: This setting lets you associate the OneTrust cookie consent groups to Google Analytics 4.
Hybrid mode
Hybrid mode sends your event data to Google Analytics 4 via both the native SDK (device mode) and the Google Analytics 4 Measurement Protocol (cloud mode).
Why hybrid mode?
Unlike GA Universal, GA4’s server-side tracking (cloud mode) is less independent and may require support from client-side tracking (device mode). As noted in Google’s docs, Measurement Protocol is meant to augment automatic collection via gtag, Tag Manager, and Google Analytics, not replace them.
Through a single hybrid mode deployment, you would have access to a fuller, more unified and accurate set of attribution data with the least impact on performance—resulting from a combination of client-side and server-side tracking. Specifically, a hybrid instrumentation may make sense for those who prefer to maintain the benefits of cloud mode—including a faster site, more reliable data collection, and first-party data capture, while also capturing data required for attribution, sessionization, geolocation, and conversions for Google Ads Remarketing.
Use hybrid mode
To use GA4 connection in hybrid mode, you can select the Hybrid mode while setting up the connection modes. This option is available only for the gtag.js web SDK.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.