# Analyze RightMessage tests in PostHog

You'll send every RightMessage A/B test version to PostHog as an exposure event, so you can analyze tests with PostHog experiments, funnels and insights.

Analyze RightMessage tests in PostHog alongside the product and revenue events you already track. RightMessage sends a custom exposure event each time it counts a visitor in a test version, so PostHog knows which version each person saw.

This covers page and audience A/B tests, campaign holdbacks, and question, form, offer and flow split tests. You can turn on the PostHog app on every plan, but impressions come only from holdbacks and A/B tests (**Scale** and **Pro**) and split tests (**Pro**). Holdbacks need **Scale** or **Pro**, and starting an A/B test needs **Pro**.

## Turn on the PostHog app

1. Open **Integrations**, then **Other integrations**.
2. On the **PostHog** card, choose **Enable**.
3. [Publish](https://rightmessage.com/help/publishing-your-changes) your changes.

RightMessage uses the `posthog` object already on your page. Load and initialize PostHog before RightMessage counts the visitor, or the event is skipped. See [send events and contact data to PostHog](https://rightmessage.com/help/posthog-integration) for the other events.

## What PostHog receives

```javascript
posthog.capture('rm_experience_impression', {
  '$feature/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',
  exp_variant_string: 'RM-cpn_5didDYbc-control'
});
```

- `$feature/rm-<experienceId>` holds the version ID. PostHog experiments read this property, and `rm-<experienceId>` is the feature flag key to use.
- `rm_experience_kind` is `holdback`, `original_test`, `audience_test`, `flow_test`, `question_test` or `offer_test`.
- `rm_campaign_id` or `rm_resource_id` appears when there is one.

To find a test's flag key, open the campaign's **Testing** tab and open **Send to your analytics** on the test. It shows the **PostHog feature flag**, each version's GA4 experiment string, and **Preview this version on your site**.

![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)

## Analyze a test in PostHog

1. In PostHog, create an experiment, or an insight broken down by the `$feature/rm-<experienceId>` property.
2. For an experiment, use `rm_experience_impression` as a custom exposure event and set the feature flag key to `rm-<experienceId>`. The variant keys are RightMessage's version IDs, such as `control`.
3. Pick the metric you care about from your own PostHog events.

RightMessage decides who sees which version. PostHog only analyzes the results, so don't let a PostHog flag also split the same traffic. Check PostHog's experiments documentation for the current setup screens.

## Check that impressions arrive

Visit a page with a running test in a browser that isn't excluded, then look for `rm_experience_impression` in PostHog's activity view.

Nothing is sent from an [excluded browser](https://rightmessage.com/help/exclude-test-visitors), in previews or debugger sessions, before cookie consent when the project [waits for consent](https://rightmessage.com/help/use-rightmessage-with-a-cookie-banner), or when `posthog.capture` isn't on the page.

PostHog's results are your own analysis. RightMessage's verdicts 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 Google tools, see [GA4 and Google Tag Manager](https://rightmessage.com/help/analyze-tests-in-ga4-and-google-tag-manager).
