RudderStack supports sending event data to Google Analytics 4 via the following connection modes:

Connection ModeWebMobileServer
Device ModeSupported--
Cloud ModeSupportedSupportedSupported
In a web device mode integration, that is, using JavaScript SDK as a source, the Google Analytics 4 native SDK is loaded 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:

  1. From your RudderStack dashboard, add the source. Then, from the list of destinations, select Google Analytics 4.
  2. Assign a name to your destination and click Continue.

Connection settings

To successfully configure Google Analytics 4 as a destination, configure the following settings:

  • API Secret: This field is required only for cloud mode setup where you can 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 the cloud and device mode both. If you select gtag, enter the below:
      • 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 below settings:
      • 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.
  • GA4 client_id Field Identifier: This field is only required while sending events to GA4 in cloud mode. Enter the identifier which RudderStack should look for in the payload and map to the GA4 client_id. For more information on client_id, refer to the Mapping client_id section.
  • Enable debug mode: In the device mode, enabling this setting lets you monitor the events in DebugView. In the cloud mode, you can check the validation responses in the Live Events tab. However, note that as per the GA4 documentation, any responses sent to the validation server will not show up in the reports.

Identify

The settings in this section are only applicable for the cloud mode.
  • Enable Server Side Identify: Enable this setting and configure the following options to make an identify call:

    • Trait to differentiate between new or existing user: Enter a trait key to determine a new or an existing user.
    • Convert identify event to Login or Signup event: Enable this setting to convert the identify event to a login event in case of an existing user or a sign_up event in case of a new user.
    If Enable Server Side Identify is enabled in the dashboard, then this setting too must be enabled to send the identify call successfully.
    • Trait key for the 'method' parameter in Login or Signup event: Enter the trait key to pass the method parameter in the login or signup event.
    • Send 'generate_lead' event for 'identify' event: Enable this setting to send a generate_lead event for a new user.
    Note that the generate_lead event will only be fired for the new users and not for the existing ones.

    When enabled and it is a new user, you also need to enter the following details:

    • Value - traits for lead generation: Enter the value key to pass the value parameter for the generate_lead event.
    • Currency - traits for lead generation: Enter the currency key to pass the currency parameter for the generate_lead event.
    Refer to the identify call payload for more information on sending identify events to GA4 via cloud mode.

Native SDK

The settings in this section are only applicable for the device mode.
  • Block a Page View Event: Enable this setting to disable sending page_view events on load. However, you can explicitly send a page_view event by calling the page() API.
  • Extend Page View Property: 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.

Send userId to GA: This setting exhibits the following behavior:

  • If enabled, the user ID is set to the identified visitors and sent as explained in the Cookies and user identification guide.
  • If disabled, userId is not sent and RudderStack only sends the user traits set as user_properties to Google Analytics. The user properties are set on the gtag client as explained in the Set user properties guide.

Client-side 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 on this feature.

Web SDK settings

  • Send only attribution or sessionization events through device mode: Enable this setting to send attribution or sessionization events through device mode. With this set to ON, and Send all other events through device mode set to OFF, you will have a hybrid mode deployment. Turning this setting OFF would mean a pure cloud mode deployment.

  • Send all other events through device mode: Enable this setting to send all non-attribution or sessionization events through device mode. With this set to ON, and the first toggle set to ON, you will have a pure device mode deployment.

  • OneTrust Cookie Categories: 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.

Get started with hybrid mode

Any new GA4 connection is set to hybrid mode by default. Currently, this setting is only applicable for the gtag.js web SDK.

To further customize your connection mode settings, navigate to the Web SDK Settings section of your RudderStack dashboard. By default, your configuration is set to hybrid mode, with Use device mode to send events set to ON and Enable pure device mode deployment set to OFF.

If you prefer to send all events through device mode, toggle Enable pure device mode deployment to ON.

If you prefer to send all events through cloud mode, toggle Use device mode to send events to OFF.

FAQ

How do I obtain the Measurement Id?

  1. Login to Google Analytics dashboard.
  2. Go to the Admin section in the left sidebar.
  3. Select the relevant account and property.
  4. Click Data Streams and select the stream to get the Measurement Id as shown:
measurement id

How do I obtain the API Secret?

  1. Login to Google Analytics dashboard.
  2. Go to the Admin section in the left sidebar.
  3. Select the relevant account and property.
  4. Click Data Streams and select the stream.
  5. Click Measurement Protocol API secrets to get the API Secret as shown:
api secret

How do I obtain the Firebase App ID?

  1. Login to Google Analytics dashboard.
  2. Go to the Admin section in the left sidebar.
  3. Select the relevant account and property.
  4. Click Data Streams and select the stream to get the Firebase App Id as shown: firebase app id

Contact us

For more information on the topics covered on this page, email us or start a conversation in our Slack community.

On this page