Setup Guide
6 minute read
This guide will help you set up Google Analytics 4 as a destination in the RudderStack dashboard. It also lists the configuration settings required to correctly send data from the supported sources to Google Analytics 4.
Connection compatibility
| Destination Information | |||
|---|---|---|---|
| |||
Setup
In your RudderStack dashboard, add a source. Then, from the list of destinations, select Google Analytics 4 (GA4) v2.
Connection settings
| Setting | Description |
|---|---|
| Name | Assign a name to uniquely identify your destination. |
| oAuth settings | Click Create Account and connect RudderStack with your Google Analytics account. Then, choose the account and click Save to proceed. |
| Protocol secrets | RudderStack automatically populates your GA4 protocol secret. In case you have set up multiple data streams, choose the relevant protocol secret from the dropdown. |
| Connection mode | Specify how you want to route the events from your source to Google Analytics 4. See the Connection mode comparison section for help. |
Configuration settings
Configure the below settings to receive your data correctly in Google Analytics 4:
Custom mappings
RudderStack supports mapping your track events (including Ecommerce events) and associated properties to specific GA4 dimensions and metrics. See the Custom Mappings guide for more information on setting up these mappings.
The mappings specified in this section take precedence over any other event transformation applicable for the destination.

Then, configure the below settings depending on your connection mode:
Cloud mode settings
| Setting | Description |
|---|---|
| Debug via Validation Server | Turn on this setting to check the validation responses in the Live Events tab. RudderStack supports the debug mode via GA4’s validation server endpoint. Note: As per the Google Analytics 4 documentation, any responses sent to the validation server will not show up in the reports. |
| Filter user traits | Enter the list of user traits you do not want RudderStack to send to GA4. You can use this field to filter sensitive PII fields from your events, like email, phone number, credit card number, etc., and prevent RudderStack from sending them to GA4. You can add multiple traits by pressing the enter key after specifying each trait. Note: This setting is applicable only for the events that are not mapped in custom mappings. |
| Consent management settings | Configure the consent management settings for the specified source by choosing the Consent management provider from the dropdown and entering the relevant consent category IDs. See Consent Management in RudderStack for more information on this feature. |
Hybrid mode settings
| Setting | Description |
|---|---|
| Debug via Validation Server | Turn on this setting to send the cloud mode events (track and group) to the GA4 validation server. Note: These events will not show up in your reports. |
| Filter user traits | Enter the list of user traits you do not want RudderStack to send to GA4. You can use this field to filter sensitive PII fields from your events, like email, phone number, credit card number, etc., and prevent RudderStack from sending them to GA4. Note: You can add multiple traits by pressing the enter key after specifying each trait. |
| Choose how to capture pageviews | From the dropdown, select RudderStack JS SDK or gtag Automated Capture depending on whether you want to send the page view events through the RudderStack JavaScript SDK or through automatic collection on each page load using Enhanced Measurement (gtag) respectively. |
| Debug via DebugView | If you turn on this setting, then the device mode events (page calls) will be visible under the GA4 DebugView section. |
| Include URL and Search as page view properties | Turn on this setting to send the following properties along with any other custom property to the page call of the RudderStack SDK:
|
| Override gtag client ID & session ID | Turn on this setting to override the gtag client_id and session_id with RudderStack’s anonymousId and session_id, ensuring that the attribution is properly unified across the page and track events.Note that:
|
| Events filtering | Specify which events should be blocked or allowed to flow through to GA4 by selecting any of the below options from the dropdown:
|
Connection mode comparison
The following table lays out a detailed comparison to help you choose a connection mode when sending events to Google Analytics 4.
Note that:
- RudderStack makes the primary decision on how to track and stitch events together based on the
client_idandsession_idparameters.- 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.
Cloud mode | Hybrid mode without client ID override (Requires SDK configuration) | ||
|---|---|---|---|
| Description | Sends data server-side to Google’s Measurement Protocol API. | 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 | 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 | 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 | 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 | To capture full attribution data, you must pass it as custom dimensions or instrument a parallel client-side integration. | Ensure that the Override gtag client ID & session ID setting is enabled in the RudderStack dashboard. To ensure accurate cross-platform analytics, check that other cookies (like Google Ads) also include the appropriate rs_ prefix. | Instrument your SDK to buffer. For example: rudderanalytics.load("write_key","dataplane_url",{bufferDataPlaneEventsUntilReady: true}); |
FAQ
How can I prevent RudderStack from sending PII fields to Google Analytics 4?
You can prevent RudderStack from sending sensitive PII data in your events to GA4 by specifying the user traits in the Filter user traits configuration setting.
You can add multiple traits by pressing the enter key after specifying each trait.
