How to Integrate Google Analytics 4 with Nelio A/B Testing
Google Analytics 4 (GA4) is the next generation of Google Analytics that enables you to collect visitor data on your websites and apps for analytical purposes.
Nelio A/B Testing makes it easy to track your test results using your preferred analytics platform. If you’re using Google Analytics 4 (GA4), you can now seamlessly integrate it with Nelio A/B Testing and track both test impressions (visits) and conversions automatically and accurately.
In this guide, you’ll learn how to configure the integration, including how events are sent to GA4 depending on whether you’re using Google Tag Manager (GTM) or not.
Overview: How Nelio A/B Testing Sends Data to GA4
Nelio A/B Testing uses different methods to send tracking data to GA4:
| Event Type | Source | Delivery Method |
|---|---|---|
| Test Views | Browser | gtag (GA4 script) or dataLayer (for GTM) |
| Conversions | Browser | gtag (GA4 script) or dataLayer (for GTM) |
| Conversions | Server | GA4 Measurement Protocol |
✅ Note: Nelio A/B Testing uses gtag or dataLayer depending on the tracking method you select in the settings (see below). For conversion events that occur on the WordPress server (form submissions, order purchases, etc.), it sends the event using the GA4 Measurement Protocol.
Guide to Integrate Nelio A/B Testing with Google Analytics 4
Prerequisites
Before enabling the integration, make sure you:
- Have a Google Analytics 4 property created.
- Have access to Admin » Data Streams » Web Stream Details for that property.
- Have created an API secret for your measurement protocol requests (explained below).
Step 1: Get Your Measurement ID and API Secret
Measurement ID
- Open Google Analytics.
- Go to Admin » Data Streams.
- Select your Web stream.
- Copy the Measurement ID (e.g.,
G-XXXXXXX).

For more details, read Google’s documentation.
API Secret
- On the same Web stream settings page, scroll to Measurement Protocol API secrets.
- Click Create API secret.
- Give it a name like “Nelio A/B Testing Integration”, then click Create.
- Copy the API Secret shown.

🔒 Keep this API secret private — anyone with it can send data to your GA4 property.
Step 2: Enable the GA4 Integration in Nelio A/B Testing
- In your WordPress dashboard, go to Nelio A/B Testing » Settings.
- Scroll to the Google Analytics 4 section.
- Enable “Send tracking events to Google Analytics 4”.
- Select whether you use Google Tag Manager or the Google tag on your site.
- Enter the data from Step 1:
- Your Measurement ID (e.g.,
G-XXXXXXXXXX) - Your API Secret
- Your Measurement ID (e.g.,
This is what it looks like:

What Events Does Nelio A/B Testing Send?
Nelio A/B Testing sends two types of events to GA4:
| Event Name | When It’s Triggered | Parameters Sent |
|---|---|---|
experiment_impression | When a visitor sees a variant | experiment_id, variant_id, goal_id |
conversion | When a goal is completed | experiment_id, variant_id, goal_id, value (optional) |
Register the Experiment Parameters in GA4
Nelio A/B Testing sends experiment_id, variant_id, and goal_id as event parameters. To use these parameters in GA4 reports, explorations, and segments, register them as event-scoped custom dimensions.
- In Google Analytics, go to Admin » Data display » Custom definitions.
- Open the Custom dimensions tab.
- Click Create custom dimension.
- Create the following dimensions:
| Dimension name | Scope | Event parameter |
|---|---|---|
| Experiment ID | Event | experiment_id |
| Variant ID | Event | variant_id |
| Goal ID | Event | goal_id |
- Save each custom dimension.
GA4 may need between 24 and 48 hours before new custom dimensions become available in reports and explorations. Custom dimensions do not provide historical reporting for data collected before they were created. Therefore, create these dimensions before starting the experiment you want to analyze.
If your conversion events include the optional value parameter, you can use GA4’s Event value metric to analyze the accumulated value of those conversions.
For additional information, see Google’s guide to creating event-scoped custom dimensions.
Important: Custom dimensions only make the collected parameters available for reporting. They do not cause Nelio A/B Testing to send any additional data.
Set Up Google Tag Manager (GTM)
If your site uses Google Tag Manager (GTM) to manage GA4, follow these additional steps to properly track Nelio A/B Testing events in GA4.
A. Create Data Layer Variables
- Go to Variables » New.
- Select Data Layer Variable. In Data Layer Variable Name, enter the parameter name, such as
experiment_id. Give the GTM variable a descriptive name, such as “DLV – experiment_id.” - Repeat for all the parameters you’ll use in the GA4 tag.
Create Data Layer Variables for experiment_id, variant_id, and goal_id. If you want to send the optional conversion value to GA4, also create a variable for value.

experiment_id value.B. Create a Custom Event Trigger
- In GTM, go to Triggers > New.
- Choose Trigger Type → Custom Event.
- Set the Event Name to:
experiment_impression(for visits)conversion(for conversions)
- Save each trigger.


C. Create GA4 Event Tags
Create one GA4 Event tag for impressions and another for conversions.
Impression tag
- Set the event name to
experiment_impression. - Add these event parameters:
experiment_idvariant_idgoal_id
- Assign the
experiment_impressiontrigger.
Conversion tag
- Set the event name to
conversion. - Add these event parameters:
experiment_idvariant_idgoal_idvalue, if available
- Assign the
conversiontrigger.
For each event parameter, select its corresponding Data Layer Variable as the value. For example, map the experiment_id parameter to the variable that reads experiment_id from the data layer.


How to Test If Events Are Being Sent
Use DebugView in Google Analytics:
- Enable GA Debugger in your browser or follow this guide.
- Visit your WordPress site in incognito mode and trigger an A/B test view and conversion (you need to have at least one test running).
- In GA4, go to Admin » DebugView and look for
experiment_impressionorconversion.
How to Analyze Experiment’s Conversions in GA4
You can compare the behavior and conversions of each experiment variant using a GA4 Exploration.
Step 1: Find the Experiment and Variant IDs
Before creating the exploration, identify the IDs you want to analyze:
experiment_ididentifies the Nelio A/B test.variant_ididentifies the alternative shown to the visitor.goal_ididentifies the conversion goal.
You can inspect an experiment_impression or conversion event in GA4’s DebugView to see the values sent for each parameter.
Step 2: Create a User Segment for Each Variant
A user segment groups together the activity of users who saw a particular variant, including conversions that might happen later in the same or a subsequent session.
- In GA4, go to Explore.
- Create a Free form exploration.
- In the Variables column, click the + next to Segments.
- Select Create a custom segment » User segment.
- Name the segment after the variant, for example, “Experiment 123 – Control.”
- Add an event condition for
experiment_impression. - Add the following parameters to the
experiment_impressionevent:- Experiment ID exactly matches the desired
experiment_id. - Variant ID exactly matches the desired
variant_id.
- Experiment ID exactly matches the desired
- Set Condition scoping to Within the same event. This ensures that the experiment and variant IDs belong to the same
experiment_impressionevent. - Click Apply to save the segment.
- Repeat these steps for each variant in the experiment.
GA4 supports up to four segment comparisons in one exploration. If your experiment has more than four alternatives, analyze them in separate tabs or explorations. For more information, see Google’s segment builder documentation.
Step 3: Build the Variant Comparison
Configure the Free form exploration as follows:
| Exploration setting | Value |
|---|---|
| Segment comparisons | The user segment created for each variant |
| Rows | Event name |
| Columns | Leave empty |
| Values | Event count and Total users |
| Filter | Experiment ID exactly matches the experiment_id being analyzed |
| Additional filter | Event name matches regex ^(experiment_impression|conversion)$ |
If Experiment ID isn’t available when creating the filter, click the + next to Dimensions in the Variables column, search for Experiment ID, select it, and click Import.
Similarly, if Total users isn’t available under Values, click the + next to Metrics, search for Total users, select it, and click Import.
The resulting table shows the experiment_impression and conversion events associated with users who saw each variant, along with the number of unique users who generated those events.
If the experiment has multiple goals, you can also filter by the Goal ID you want to analyze. If Goal ID isn’t available, import it first from Dimensions, as described above. Without this filter, the conversion row may include conversions from multiple goals.
Step 4: Interpret the Results
FThe exploration lets you compare both unique users and event counts for each variant.
Using Total users, you can calculate the percentage of users exposed to a variant who generated at least one conversion:
For example, if 1,000 users saw a variant and 120 of those users generated at least one conversion, 12% of the users exposed to that variant converted.
You can also use Event count to compare the total number of conversion events generated by users exposed to each variant. This can be particularly useful when visitors can convert more than once.
These GA4 metrics provide additional ways to analyze the behavior of users exposed to each variant, but they shouldn’t be interpreted as the conversion rate reported by Nelio A/B Testing. Nelio calculates its experiment results from the visits and conversions it tracks and performs its own statistical analysis to determine how each variant performs.
Use Nelio A/B Testing as the source for the experiment’s conversion rates and statistical results, and use GA4 Explorations to perform additional analysis of the users exposed to each variant.
For example, after creating the basic comparison above, you can add dimensions such as Device category, traffic source, or country to investigate whether users exposed to the variants behaved differently across particular audiences.
Note: GA4 and Nelio A/B Testing may not display identical totals. Differences can result from factors such as consent settings, ad blockers, browser restrictions, GA4 processing, reporting delays, and the selected date range.
If you’re unsure about any of these steps or want us to double-check your setup, get in touch with our support team — we’re happy to help!
Did you find this useful?
Thanks for your feedback!
Not what you’re looking for? Ask us directly:


