Sending your A/B test groups to GA4 with Google Tag Manager
CategoryIntegrations › Connectors
CreatedNov 25, 2026
UpdatedNov 25, 2026
Pathmonk can tell Google Analytics 4 which A/B group each visitor is in, so you can compare the groups inside GA4 with your own reports. This is an advanced set-up for teams that want that specific data in GA4. For the standard connection, see Managing your Google Analytics 4 connection. This article covers the method with Google Tag Manager. For the method with code, see Sending Pathmonk data to GA4 directly.
Before you start
- Pathmonk is installed through Google Tag Manager.
- You can edit your Google Tag Manager container and your GA4 property.
The three groups
| GA4 event | The visitor |
|---|---|
pathmonk_displaying | Enabled: is in the Pathmonk group and can see micro-experiences |
pathmonk_not_displaying | Control group: Pathmonk is active for this visitor but does not show micro-experiences |
pathmonk_analytics_only | No group: was tracked after the snippet was installed but before Pathmonk was published, so could not be placed in either group |
For how the groups work, see How traffic is split: the control group.
Step 1: create the three events in GA4
- In Google Analytics, open Admin.
- Under Data display, click Events.
- Click Create event, then Create.
- Under Custom event name, type
pathmonk_displaying. - Set the matching condition: parameter event_name, operator equals, value
pathmonk_displaying. - Click Save.
- Repeat for
pathmonk_not_displayingandpathmonk_analytics_only.
Step 2: add a listener tag in Google Tag Manager
- In Google Tag Manager, open Tags and click New.
- Name it, for example
[SETUP] Listen to Pathmonk events. - Choose the tag type Custom HTML and paste:
<script>
document.addEventListener("pathmonkControlGroupPathmonk", function() {
window.dataLayer.push({ 'event': 'pathmonk_displaying', 'pathmonk_user': 'pathmonk_displaying' });
});
document.addEventListener("pathmonkControlGroup", function() {
window.dataLayer.push({ 'event': 'pathmonk_not_displaying', 'pathmonk_user': 'pathmonk_not_displaying' });
});
document.addEventListener("pathmonkControlGroupDisabled", function() {
window.dataLayer.push({ 'event': 'pathmonk_analytics_only', 'pathmonk_user': 'pathmonk_analytics_only' });
});
</script>
- Set the trigger to All Pages and save.
- Open the tag that holds your Pathmonk snippet, open Tag Sequencing, tick Fire a tag before this tag fires and choose the listener tag. Save.
The listener must fire before Pathmonk, or it misses the event.
Step 3: add one GA4 tag per group
- In Tags, click New and name it, for example
[GA4] pathmonk_displaying. - Choose the tag type Google Analytics: GA4 Event.
- Enter your GA4 Measurement ID.
- Enter the event name
pathmonk_displaying. - Add a trigger of type Custom Event with the event name
pathmonk_displaying. - Save.
- Repeat for
pathmonk_not_displayingandpathmonk_analytics_only.
Step 4: test and publish
- Click Preview in Google Tag Manager and open your website.
- Check that the listener tag and one of the three GA4 tags fire.
- Check that the event appears in GA4 under Admin > DebugView.
- Publish the container.
If you get stuck, contact our support team. Our developers can help you with the set-up.
