The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsProduct feedbackGitHubNuGetDev CommunitySubmit a ticketLog In

Integrate Google Analytics 4 with Google Tag Manager

Enable Optimizely Web Experimentation's built-in Google Analytics 4 integration with Google Tag Manager.



See Optimizely's Third-Party Add-Ons & Platform Integration Terms.

Using Optimizely's built-in Google Analytics 4 (GA4) integration, you can integrate with Google Tag Manager (GTM) if you use GTM as a tag management system to add and update your own tags for conversion tracking and site analytics or if you have the GTM script installed on the page.

  1. Complete steps 1 and 2 to configure GA4.
  2. Select the Use Google Tag Manager for this integration checkbox then click Save.
  1. Follow the sections below to add user-defined variables, set up the configuration tag, and set up the event tag for Google Analytics 4 (GA4).

Add User-Defined Variables in GTM

  1. Go to Workspace > Variables > New.
  1. Enter exp_variant_string in the Untitled Variable field.
  2. Click Variable Configuration and select Data Layer Variable.
  1. Enter exp_variant_string for the Data Layer Variable Name.
  2. Select Version 2 for the Data Layer Version.
  1. Click Save.

Set up the configuration tag in GTM



This section connects GTM with GA4. If you already have a configuration tag, you can skip this section and set up the event tag .

  1. Go to Workspace > Tags > New.
  1. Enter Google Analytics - GA4 Configuration in the Untitled Tag field.
  1. Click Tag Configuration and select Google Analytics > Google Tag.
  1. 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.
  1. Expand Configuration settings and click Add parameter. Select None in the dropdown list for Configuration Settings Variable, input send_page_view for Configuration Parameter, and set the Value to true.
  1. Click Triggering and select Initialization - All Pages.
  1. Click Save.

Set up the event tag in GTM

  1. Go to Workspace > Tags > New.
  1. Enter Optimizely Web - GA4 Event in the Untitled Tag field.
  2. Click Tag Configuration and select Google Analytics > Google Analytics: GA4 Event.
  1. Enter your Measurement ID from GA4.
  1. Enter experience_impression in the Event Name.
  2. Expand Event Parameters and then click Add Parameter.
  3. Enter exp_variant_string in the Parameter Name.
  4. Click the Value Select icon and choose exp_variant_string.
  5. Click Triggering and click the New Trigger icon.
  6. Enter Optimizely X - GA4 event trigger in the Untitled Trigger field.
  1. Click Trigger Configuration and select Custom Event.
  1. Enter experience_impression in the Event Name.
  2. Click Save and then click Save again on the overall tag setup page.
  3. Submit and publish your workspace changes by going to Workspace >Β  Submit > Publish (adding any details you would like to the Submission Configuration).

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.