Skip to main content

Overview

Enabling the Google Analytics 4 integration allows Statsig to send logged events and exposures to GA4. This enhances your existing Google Analytics tracking with additional data collected by Statsig's logging SDKs.

Once enabled, Statsig will forward exposures and logged events to a configured Data Stream. These events can be filtered with event filtering.

Benefits of using the Google Analytics 4 integration

Using the GA4 Integration allows you to log additional events without having the orchestrate two libraries, thus simplifying your code. Furthermore by implementing this integration, you'll be able to join data about experiments you create in Statsig to existing analytics events you care about in Google Analytics, giving you greater insights into different experiments' impact on your user interactions.

Configuring outbound events to Google Analytics 4

To send events collected by Statsig's SDKs to GA4, you must configure a Data Stream and provide a few pieces of information.

  1. Navigate to the GA4 admin settings. Under your app's property click Data Streams and select the stream you'd like to use. If you don't have a stream you'll need to create one.

  2. Statsig requires an API secret to send the data to your stream, navigate to your stream and create a new secret:

  3. Once created, copy the API secret and the measurement ID (optional). Navigate to your Statsig Project -> Project Settings -> Integrations -> Google Analytics (click enable) -> Google Analytics 4.

    Provide your API Secret and measurement ID from the previous step and click confirm:

  4. Verify that you are receiving events now by checking the Realtime overview report for the event with name statsig. Account for a couple days of delay for events to be available in other reports.

  5. You can also add the following custom event dimensions. Other custom IDs and custom user attributes are available as user dimensions

  • config - Name of the experiment/gate/dynamic config
  • group - Name of the exposed group (e.g. Control)
  • value - Value for custom events
  • statsig_session_id - Session ID
  • category - Type of exposure or name of the custom event (e.g. statsig_gate_exposure)
  • unit_id - Value of the unit ID (e.g. '123')
  • unit_id_type - Type of the unit ID (e.g. 'stableID')

Filtering Events

Once the outgoing integration has been enabled, you can optionally configure event filtering to control whch events are populating the GA4 Data Stream: