# Analyze RightMessage tests in GA4 and Google Tag Manager

You'll send every RightMessage A/B test version to Google Analytics 4 or your Tag Manager data layer, so you can compare versions with the rest of your analytics.

See which RightMessage test version each visitor saw right inside Google Analytics 4, next to the revenue, funnels and audiences you already track there. RightMessage sends it automatically once an analytics app is on. You don't tag anything per test.

This works for page and audience A/B tests, campaign holdbacks, and question, form, offer and flow split tests. You can turn on the analytics apps on every plan, but impressions come only from holdbacks and A/B tests (**Scale** and **Pro**) and split tests (**Pro**). Holdbacks and the **Send to your analytics** panel need **Scale** or **Pro**, and starting an A/B test needs **Pro**.

## Choose how impressions reach Google

| Your site runs…                                | Turn on                | What RightMessage sends                                     |
| ---------------------------------------------- | ---------------------- | ----------------------------------------------------------- |
| GA4 with `gtag.js` on the page                 | **Google Analytics**   | A GA4 `experience_impression` event                         |
| GA4, or other tags, through Google Tag Manager | **Google Tag Manager** | A `dataLayer` push with `event: 'rm_experience_impression'` |

You can turn on both. The two event names differ, so one impression is never counted twice.

1. Open **Integrations**, then **Other integrations**.
2. Choose **Enable** on the **Google Analytics** card, the **Google Tag Manager** card, or both.
3. [Publish](https://rightmessage.com/help/publishing-your-changes) your changes. Impressions go only to enabled, published apps.

![Google Tag Manager integration card that sends RightMessage test impressions to your data layer, with its Enable button](https://rightmessage.com/help/screens/integrations-google-tag-manager.light.webp)

RightMessage doesn't install Google Analytics or Tag Manager. It uses the `gtag` function or `dataLayer` already on your page.

## Use the GA4 event

Each time RightMessage counts a visitor in a test version, it calls:

```javascript
gtag('event', 'experience_impression', {
  exp_variant_string: 'RM-cpn_5didDYbc-control',
  rm_experience_name: 'Pricing page campaign · Holdback',
  rm_variant_name: 'Held back'
});
```

`exp_variant_string` is `RM-<experienceId>-<variantId>`, the format GA4's experiment reporting reads. To break reports down by version:

1. In GA4, open **Admin**, then **Custom definitions**.
2. Create an event-scoped custom dimension for the parameter `exp_variant_string`. Add `rm_variant_name` too if you'd like readable names.
3. Wait for new data. GA4 doesn't fill in custom dimensions for events it collected earlier.

Then compare your conversions or revenue by `exp_variant_string` in an exploration.

## Use the Google Tag Manager event

With the **Google Tag Manager** app on, each impression is pushed to your data layer:

```javascript
{
  event: 'rm_experience_impression',
  exp_variant_string: 'RM-cpn_5didDYbc-control',
  rm_experience_id: 'cpn_5didDYbc',
  rm_experience_kind: 'holdback',
  rm_experience_name: 'Pricing page campaign · Holdback',
  rm_variant_id: 'control',
  rm_variant_name: 'Held back',
  rm_campaign_id: 'cpn_5didDYbc',
  rm_resource_id: null
}
```

Every key is present on every push, and `null` when it doesn't apply. `rm_experience_kind` is `holdback`, `original_test`, `audience_test`, `flow_test`, `question_test` or `offer_test`.

1. In Tag Manager, create Data Layer Variables for `exp_variant_string` and any other keys you need.
2. Create a **Custom Event** trigger with the event name `rm_experience_impression`.
3. Add a tag that fires on it, such as a GA4 event tag that sends `exp_variant_string` as a parameter, or a tag for another analytics tool.
4. Preview, then publish your container.

## Find each version's string

On the campaign's **Testing** tab, open **Send to your analytics** on a test. It lists each version's GA4 experiment string with a copy button, plus the **Google Tag Manager event** name and the **Page event** name. **Preview this version on your site** opens your site showing that version. Before the test starts, the panel says "Starts sending when the test starts."

![Send to your analytics panel listing the experience values each version sends to Google Analytics, Google Tag Manager and PostHog](https://rightmessage.com/help/screens/testing-send-to-analytics.light.webp)

## Check that impressions arrive

Visit your site in a browser that isn't excluded, on a page with a running test, and look for the event in GA4's DebugView or realtime report, or in Tag Manager's preview.

Nothing is sent:

- from a browser you've [excluded](https://rightmessage.com/help/exclude-test-visitors), including any browser that has opened the debugger;
- in previews and debugger sessions;
- before cookie consent, when the project [waits for consent](https://rightmessage.com/help/use-rightmessage-with-a-cookie-banner);
- when `gtag` isn't on the page, for the Google Analytics app.

Your analytics counts are your own analysis. RightMessage's verdicts on the **Testing** tab use its own weekly checks. See [read A/B test results](https://rightmessage.com/help/read-ab-test-results-and-test-with-low-traffic). For other tools, use [PostHog](https://rightmessage.com/help/analyze-tests-in-posthog) or the `rm:experience-impression` [page event](https://rightmessage.com/help/javascript-hooks).
