Send Events to GA4 via DataLayer

Overview

Following the steps in this article, you'll use the DataLayer integration available in your Explore account to send experiment-related events into your GA4 property whenever visitors browse pages affected by your experiments.

This guide assumes you already have some knowledge of web analytics tracking, and that you've already created and installed a Google Tag Manager (GTM) web container on your website that sends data to your GA4 property.

Warning

If you perform the steps below while also having the Google Analytics Integration active in your Explore Integrations section, you'll effectively double your GA4 events - once via the Explore Integration and once via the dataLayer/GTM integration - affecting data quality and your analysis.

Step 1 - Activate the DataLayer integration in Explore

  1. Select your website from your Explore account, then click Integrations from the dropdown menu.

  2. Scroll to the Google Tag Manager section and input exactly dataLayer into the Data Layer variable name field.

  3. Click Enable to activate the integration.

Once enabled, you'll start receiving Omniconvert events in your website's dataLayer whenever a visitor sees a variation of an Explore experiment.

Every Omniconvert event has an Event Name of Omniconvert, and includes two variables:

  • mktzExperiment: [ExperimentID]Experiment Name

  • mktzVariation: [VariationID]Variation Name

We'll now use Google Tag Manager's ability to create and customize GA4 events to send this data to your GA4 property.

Step 2 - Creating the tag

  1. From your GTM workspace, go to Tags.

  2. Click New.

  3. Click Tag Configuration.

  4. Select Google Analytics from the Featured section.

  5. Select Google Analytics: GA4 Event as the tag type.

  6. Name the tag GA4 - omniconvert.

If you already have another GA4 tag in GTM, copy the GA4 Measurement ID from it into this new tag.

Obtaining the Measurement ID (if you don't have another GA4 tag)

  1. Go to your Google Analytics account.

  2. Open Admin via the cog icon in the bottom right.

  3. Under Data collection and modification, click Data streams.

  4. Click your web data stream.

  5. Copy the GA4 Measurement ID and paste it into the GA4 - omniconvert tag's Measurement ID field.

Set the Event Name to omniconvert - this is the unique event you'll see in GA4 after publishing the tag.

Step 3 - Defining the experiment variables

  1. Expand Event Parameters and add two empty parameters.

  2. Define the first as exp_name, holding the value of the mktzExperiment dataLayer variable.

  3. Define the second as exp_var, holding the value of the mktzVariation dataLayer variable.

To create each dataLayer variable: type #{{ in the Event Parameter Value box, scroll to the bottom of the dropdown, and select New Variable (or click the Event Parameter Value button and the + symbol in the variable list).

  1. Choose the Data Layer Variable type.

  2. Give it a descriptive name, e.g. dl - experiment name.

  3. Input exactly mktzExperiment as the Data Layer Variable Name and click Save.

  4. Repeat for the second variable: name it dl - experiment variation, and input exactly mktzVariation as the Data Layer Variable Name.

At this stage, the tag should show both parameters configured:

Step 4 - Creating a trigger

  1. Click Triggering below the tag, then the + symbol, then Trigger Configuration.

  2. Select Custom Event as the trigger type.

  3. Name the trigger event - omniconvert, and input exactly Omniconvert into the Event Name field.

  4. Click Save.

Defining custom dimensions in GA4

For exp_name and exp_var to be recognized in GA4, define them as custom dimensions first:

  1. Go to your Google Analytics account.

  2. Open Admin via the cog icon.

  3. Under Data Display, click Custom Definitions.

  4. Click Create custom dimension.

  5. Input exactly exp_name in both the Dimension name and Event parameter fields, set Scope to Event, and click Save.

  6. Repeat for exp_var.

The end result should show both custom dimensions listed:

Once both custom dimensions are defined, verify and publish your GTM container changes - add a Version Name and Description for easier tracking, then click Publish.

Warning

Data only collects when visitors interact with a page affected by an active Explore experiment, triggering the GA4 - omniconvert tag via the active GTM integration. Allow up to 24 hours for event data to populate in GA4 after publishing, or from the first triggered event.

Step 5 - Visualizing the data

We recommend using GA4's Exploration reports for custom visualization. For more advanced needs, tools like Looker Studio can import GA4 data directly.

Building an Exploration report

  1. Go to the Explore section of your GA4 property.

  2. Create a Blank exploration report and name it (e.g. Omniconvert events).

  3. Click + next to DIMENSIONS, search event, and select Event name.

  4. Search exp and select both exp_name and exp_var custom dimensions, then confirm.

  5. Click + next to METRICS, search and select Sessions, Total users, and Event count, then confirm.

  6. Double-click each dimension and metric to add them to the Free form 1 report - dimensions go to Rows, metrics to Values automatically.

  7. In the Settings pane, scroll to FILTERS, select the Event name dimension, set Condition to exactly matches, and input omniconvert, then Apply.

  8. Select different date ranges to see how many users, sessions, or omniconvert events were collected in that timeframe.

Updated