PathmonkHelp
Help/Integrations/Connectors/Sending your A/B test groups to GA4 with Google Tag Manager

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 eventThe visitor
pathmonk_displayingEnabled: is in the Pathmonk group and can see micro-experiences
pathmonk_not_displayingControl group: Pathmonk is active for this visitor but does not show micro-experiences
pathmonk_analytics_onlyNo 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

  1. In Google Analytics, open Admin.
  2. Under Data display, click Events.
  3. Click Create event, then Create.
  4. Under Custom event name, type pathmonk_displaying.
  5. Set the matching condition: parameter event_name, operator equals, value pathmonk_displaying.
  6. Click Save.
  7. Repeat for pathmonk_not_displaying and pathmonk_analytics_only.

Watch this step on video

Step 2: add a listener tag in Google Tag Manager

  1. In Google Tag Manager, open Tags and click New.
  2. Name it, for example [SETUP] Listen to Pathmonk events.
  3. 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>
  1. Set the trigger to All Pages and save.
  2. 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.

Watch this step on video

Step 3: add one GA4 tag per group

  1. In Tags, click New and name it, for example [GA4] pathmonk_displaying.
  2. Choose the tag type Google Analytics: GA4 Event.
  3. Enter your GA4 Measurement ID.
  4. Enter the event name pathmonk_displaying.
  5. Add a trigger of type Custom Event with the event name pathmonk_displaying.
  6. Save.
  7. Repeat for pathmonk_not_displaying and pathmonk_analytics_only.

Watch this step on video

Step 4: test and publish

  1. Click Preview in Google Tag Manager and open your website.
  2. Check that the listener tag and one of the three GA4 tags fire.
  3. Check that the event appears in GA4 under Admin > DebugView.
  4. Publish the container.

If you get stuck, contact our support team. Our developers can help you with the set-up.