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.
SDK Base URL: Enter the custom domain you want to use as the native SDK’s base URL. RudderStack loads the gtag.js in the {SDK_Base_URL}/gtag/js?id=${measurementId} format. The default value for the SDK base URL is https://www.googletagmanager.com/.
In 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. To load the native SDK from a custom domain, use the SDK Base URL setting in the RudderStack dashboard. Based on your website’s content security policy, you might need to allowlist this domain to load the Google Analytics 4 SDK successfully.
Connection mode comparison: hybrid vs. cloud vs. device
The following table lays out a detailed comparison to help you choose a connection mode:
Note that:
RudderStack makes the primary decision on how to track and stitch events together based on the client_id and session_id parameters.
Server-side session tracking supports only a subset of user dimensions. Google’s Measurement Protocol API does not support the reserved fields like location, demographics, predefined user dimensions, and device-specific information.
Automatically configures a single connection that captures attribution data from page calls (sent via device mode) and all other calls via cloud mode.
Automatically configures a single connection that captures attribution data from page calls (sent via device mode) and all other calls via cloud mode.
Client ID
Fetches the client_id automatically generated by gtag.
You can send a custom client_id via externalID. Otherwise, RudderStack sends an anonymousId or rudderId. See Mapping client_id.
Overrides the client_id with RudderStack’s anonymousID. (RudderStack utilizes a cookie that adds an rs_ prefix to the existing Measurement ID)
Fetches the client_id automatically generated by gtag.
Session ID
Fetches the session_id automatically generated by gtag.
Passes session_id automatically but you can customize it using these mappings.
Overrides session_id with the RudderStack’s session_id.
Fetches the session_id automatically generated by gtag.
Considerations
Offers full information capture but it’s worth noting potential impacts the performance, page speed, data resilience, and first-party data capture.
Google’s Measurement Protocol doesn’t support passing certain reserved fields, including attribution data.
Introducing a custom client_id may cause fragmentation in multi-domain implementations. You may observe a potential momentary spike in session count while switching from device mode initially.
Buffer the SDK with a slight delay to avoid a potential race condition whereby the SDK events reach GA4 prior to the events sent via server-side.
Required actions
NA
To capture full attribution data, you must pass it as custom dimensions or instrument a parallel client-side integration.
Ensure that the override setting is enabled in the RudderStack dashboard. To ensure accurate cross-platform analytics, check that other cookies (such as Google Ads) also include the appropriate rs_ prefix.
Instrument your SDK to buffer.
For example: rudderanalytics.load( "write_key", "dataplane_url", { bufferDataPlaneEventsUntilReady: true } );
Configuration settings
In the Configuration tab of your destination, you can configure the below-mentioned cloud and device mode settings:
Cloud mode
Debug via Validation Server: Enable this setting to check the validation responses in the Live Events tab. Debug mode is supported via GA4’s validation server endpoint.
As per the GA4 documentation, any responses sent to the validation server will not show up in the reports.
Filter user traits: Enter the list of user traits which you do not want RudderStack to send to GA4. You can use this field to filter sensitive PII fields like email, phone number, credit card number, etc. from your events and prevent them from being sent to GA4.
To specify multiple traits, press the enter key after each trait.
Device mode
Filter user traits: Enter the list of user traits which you do not want RudderStack to send to GA4. You can use this field to filter sensitive PII fields like email, phone number, credit card number, etc. from your events and prevent them from being sent to GA4.
To specify multiple traits, press the enter key after each trait.
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. See GA4 documentation for more information.
Debug via DebugView: This setting lets you monitor the device mode events in DebugView. It displays the events and user properties that GA4 collects in realtime. With this feature, you can troubleshoot issues as you install your tags or go through a user’s live activity.
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.
Hybrid mode
Debug via Validation Server: If you enable this setting, then RudderStack sends the cloud mode events (track and group calls) to the GA4 validation server. These events will not show up in your reports.
Filter user traits: Enter the list of user traits which you do not want RudderStack to send to GA4. You can use this field to filter sensitive PII fields like email, phone number, credit card number, etc. from your events and prevent them from being sent to GA4.
To specify multiple traits, press the enter key after each trait.
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. See GA4 documentation for more information.
Debug via DebugView: If this setting is enabled, then the device mode events (page calls) will be visible under the GA4 DebugView section.
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
Override gtag client ID & session ID: Enable this setting to override the gtag client_id and session_id with RudderStack’s anonymousId and session_id to ensure that the attribution is properly unified across the page and track events.
If you are transitioning to the GA4 hybrid mode from device mode, enabling this setting could lead to a momentary spike in session counts. To avoid this scenario, disable this setting and buffer the SDK instead.
For all other scenarios, you can enable this setting.
Other settings
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. See Client-side Event Filtering for more information.
| Consent management provider | Configure the consent management settings for the specified source by choosing the consent management provider from the dropdown.
Click Data Streams and select the stream to get the Firebase App Id:
How can I prevent RudderStack from sending PII fields to Google Analytics 4?
To prevent RudderStack from sending sensitive PII data in your events to GA4, specify the user traits in Filter user traits while configuring your destination settings.
To specify multiple traits, press the enter key after each trait.
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.