---
title: Integrate Google Analytics 4 with Google Tag Manager
slug: web-experimentation/docs/integrate-ga4-gtm
docTags: 
createdAt: 2026-07-23T11:40:25.851Z
---

:::hint{type="info"}
This is a third-party integration and is not an Optimizely subprocessor. See Optimizely's [Third-Party Add-Ons & Platform Integration Terms](https://www.optimizely.com/legal/third-party-add-ons-platform-integration-terms/).
:::

## Prerequisites

- A [Google Analytics 4 (GA4) account](https://support.google.com/analytics/answer/9304153) with a data stream and configured data collection.
- A [Google Tag Manager (GTM) account](https://support.google.com/tagmanager/topic/14841964?hl=en\&ref_topic=15191151,3441645,2789291,\&sjid=7339326114059102812-NA) with a container and Google tag.

:::hint{type="warning"}
**🚧 Important**
Ensure you place the GTM `<script>` (see [step 5a in Google's documentation](https://support.google.com/tagmanager/answer/14847097?hl=en\&ref_topic=14841964\&sjid=10557513677172920880-NC)) as close to the Web Experimentation snippet as possible in your website's `<head>` tag. Then place the GTM `<noscript>` (see [step 5b in Google's documentation](https://support.google.com/tagmanager/answer/14847097?hl=en\&ref_topic=14841964\&sjid=10557513677172920880-NC)) immediately after the `<body>` tag. This helps prevent data discrepancies by ensuring both the Web Experimentation snippet and GTM scripts execute around the same time.
:::

- An Optimizely Web Experimentation account.
- A configuration tag to connect GTM with GA4.

## Configure GA4 with GTM in Web Experimentation

:::hint{type="info"}
**📘 Note**
You must be a **Project Owner** (or above) in Web Experimentation to enable the integration.
:::

Complete the following steps to integrate GA4 with GTM in Web Experimentation:

### Enable the GA4 integration

1. Go to **Settings > Integrations**.
2. Click **Google Analytics 4 - Report Generation**.
3. Click the toggle to turn on the integration and click **Accept**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/NasAxnQfzgXlEfN9wY7Uk_6709bbf-screenshot-2024-03-07-at-95653-am.png)

4. (Optional) Select the **Enable the Google Analytics 4 integration by default for all new experiments** checkbox to automatically send data to GA4 for new experiments. If you do not enable this, then you must [manually enable it within each experiment](docId\:bl7Kf7SQDgmer6F4-guiG) that you want to track with GA4.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/DYG44Ue0xVd1hIeWL3Ebm_213636ea52db0d3edcd2a92ce9d972ffa052ce20cb09ecbe2b09fda2ac1bf32f-image.png)

5. Select the **Enable integrating using GTM by default for existing and new experiments** checkbox to send data to GA4 through GTM for existing and new experiments, increasing the accuracy of analytics and letting you manage and deploy tags.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/sv18SAwuHv_bE6GuCL-sN_6318e57e7638f1fc96f24d5fa424d97f00833d505ba0c67680fb2868c8294bc1-image.png)

6. Click **Save**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/er05iV_-JOLrJK5bX9fcK_2b3d83d18110ecc31fa48ddbfeea0df6cc9a63775a5f3a74d38846da237c2e44-image.png)

### Add GA4 to an experiment

:::hint{type="info"}
**📘 Note**
You only need to complete these steps if you did not enable the integration setting to automatically send data to GA4 for new experiments.
:::

When you enable the GA4 integration in your account, it displays as an option on your experiments' **Integrations** page. Complete the following steps for each experiment that you want to track in GA4:

1. Go to **Integrations** in an experiment.
2. Select the **Tracked** checkbox on each experiment to send data to GA4 if you did not enable the built-in integration by default for new experiments.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/0qz-vVYpUDAqyFbOOwCE9_daa5ca7-image.png)

3. Click **Save**.

### Add user-defined variables in GTM

1. Go to **Workspace > Variables > New**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/RDXz_XsXVR2Iuq0V86C33_d988c72-image.png)

2. Enter *exp\_variant\_string* in the **Untitled Variable** field.
3. Click **Variable Configuration** and select **Data Layer Variable**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/31bS_2EsW11JTmqmgPpe9_27fc3a8-image.png)

4. Enter *exp\_variant\_string* for the **Data Layer Variable Name**.
5. Select **Version 2** for the **Data Layer Version**.
6. Click **Save**.
7. Repeat steps 1-6 with the following new information:
   - Enter `Holdback` in the **Untitled Variable** field.
   - Enter `Holdback` for the **Data Layer Variable Name**. This is case-sensitive.

The following image is an example of how the user-defined variables should look:

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/yu8AiYOMkPwhLvd5FcSRV_43d7cc9fecb0590f8754036f516cf7ca595a13c16246a16a8299d38ae6b60113-gtm-user-defined-variables.webp)

### Configure the event tag in GTM

1. Go to **Workspace > Tags > New**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/Q0bz8AEobQWSG_wLLQcGA_e93505a-screenshot-2024-03-05-at-81712-am.png)

2. Enter **Optimizely Web - GA4 Event** in the **Untitled Tag** field.
3. Click **Tag Configuration** and select **Google Analytics** > **Google Analytics: GA4 Event**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/JNMyhEHEfMZPLs_KBDraZ_e73e489-ga4-event.png)

4. Enter your **Measurement ID** from GA4.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/NagMfFHXzRhtwowUcZtdr_58cfacc-measurement-id.png)

5. Enter *experience\_impression* in the **Event Name**.
6. Expand **Event Parameters** and then click **Add Parameter**.
7. Enter *exp\_variant\_string* in the **Parameter Name**.
8. Click the **Value Select** icon and choose `exp_variant_string`.
9. Click **Add Parameter**.
10. Enter `Holdback` in the **Parameter Name**. This is case-sensitive.
11. Click the **Value Select** icon and choose `Holdback`. The following image is an example of how the GA4 event tag should look:

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/56sN-mIgMp9bSIStah9oJ_6aeddfe9d56e6b2fb90f2a285b0725e11d0c9e4d104da1ea2a0558e012babc58-ga4-event-tag.webp)

12. Click **Triggering** and click **New Trigger**.
13. Enter *Optimizely X - GA4 event trigger* in the **Untitled Trigger** field.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/8ny5xBjJoUPi0YKeJ_cwY_5253727-image.png)

14. Click **Trigger Configuration** and select **Custom Event**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/V-oI69NZNSTW2e-DpAuNz_c81894a-image.png)

15. Enter *experience\_impression* in the **Event Name**. The following image is an example of how the trigger should look:

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/cYRM_HBZ1BX444KNO5Dlh_d92e2ef702fb95e7f8bbc170c9c5dc938395611890e558e5ecd47eb26ba7206e-gtm-trigger.webp)

16. Click **Save** and then click **Save** again on the overall tag configuration page.
17. Submit and publish your workspace changes by going to **Workspace >  Submit > Publish** (adding any details you would like to the **Submission Configuration**).

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/QU6CbOkaDMVK7FA_dDXtl_082f0b6-image.png)

Your data immediately starts syncing to GA4. You should see the `experience_impression` event name display in the Realtime report once events are triggered within the last 30 minutes.

## Troubleshoot

**I do not see any visitors in the exported GA4 audiences.**

If your audiences do not have visitors, either the `experience_impression` events are not sent to GA4, or the event does not have the parameters `exp_variant_string` and `Holdback` in that exact form. Follow the steps to [add user-defined variables](docId\:riUIo7SuA5g4XVNhY7y_5) and [configure the event tag](docId\:riUIo7SuA5g4XVNhY7y_5).

These elements are required to integrate with GTM. The integration pushes `experience_impression` to the dataLayer whenever a decision is taken for the visitor. GTM must pick up the event, parameters, and variables from the dataLayer and pass it on to GA4. If the variables and parameters are not named correctly, the GA4 Report Generation feature does not receive them because it expects certain names.

**I do not have a configuration tag.**

If you have not connected GTM with GA4, follow these steps for the configuration tag:

1. **Go to Workspace > Tags > New**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/YH5Oqj2UX58Zg28fhhLIj_f403351-screenshot-2024-03-04-at-105109-am.png)

2. Enter *Google Analytics - GA4 Configuration* in the **Untitled Tag** field.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/uCtoYikf2FE_RhCNw53oI_76aa4c2-image.png)

3. Click **Tag Configuration** and select **Google Analytics** > **Google Tag**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/YDfbRFx_yqnFA8HFKL7Wy_8627b22-google-tag.png)

4. Enter your **Tag ID**. This is the same as your GA4 Measurement ID which can be found in your GA4 property under **Admin Settings > Data Streams**. Select the appropriate data stream to find your **Measurement ID**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/TQASQyRGln06Z-_9u4aHX_1c85a60-configuration-tag-setup.png)

5. Expand **Configuration settings** and click **Add parameter**. Select **None** in the drop-down list for **Configuration Settings Variable**, enter *send\_page\_view* for **Configuration Parameter**, and set the **Value** to `true`.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/3HPRXE8SNa6x07_RRUWA9_c0fc84a-screenshot-2024-01-24-at-14210-pm.png)

6. Click **Triggering** and select **Initialization - All Pages**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/sTXmfh8D2_bvehLuBC7Rb_91c7c61-image.png)

7. Click **Save**.
