See your A/B tests in Google Analytics 4

Send which test version each visitor saw to GA4 or Tag Manager, and compare the versions in your own GA4 reports.

In this article

This helps when you want to look at a test next to your other GA4 data, for example per campaign. Varly uses Google's standard event for testing tools, experience_impression. Varly's own results stay the place to pick a winner. See Read your test results.

Choose how test data reaches GA4

  1. Go to Settings → Experiments, to the card See your tests in Google Analytics 4.
  2. Under Send test data to GA4, choose one option:
    • Automatic (recommended): through Tag Manager or the Google tag, whichever your site uses.
    • Only through Google Tag Manager
    • Only through the Google tag (gtag.js)
    • Don't send anything to GA4
  3. Under GA4 Measurement ID, fill in your ID, for example G-ABC123XYZ. In GA4 you find it under Admin → Data streams: click your website stream. You need it for the Tag Manager file.
  4. Click Save. The snippet picks this up within a minute.

The Install page shows the same choice under 6. Where do you want to read test results?

If you use Google Tag Manager

Varly hands the data to Tag Manager, but Tag Manager needs a tag to pass it on to GA4. Varly makes that tag for you:

  1. Save your GA4 Measurement ID first. Then the link Download the Tag Manager file appears.
  2. Download the file.
  3. In Tag Manager, go to Admin → Import container and choose the file.
  4. Choose your workspace and Merge (if Tag Manager asks, rename conflicting tags), then confirm.
  5. Publish your container in Tag Manager, as you normally do.

The file adds one tag, Varly - GA4 experience_impression, with its trigger and variables. You only do this once per site: new tests use the same tag.

What GA4 receives

Once per visit per test, for every visitor who takes part, GA4 gets the event experience_impression with these details:

  • exp_variant_string: test and version as VARLY-<test>-<version>, for example VARLY-3f2b8c1e4a5d-b for variant B or …-control for the original. The middle part is the start of the test's code in the address of its page in Varly, without dashes.
  • varly_experiment_id and varly_experiment_name: the test's code and name.
  • varly_variant_id and varly_variant_name: the version, for example b and "Variant B".
  • varly_is_control: true for the original.

Only visitors who accepted cookies take part in tests, so only they are sent. Visitors in a dry run are sent too, so in GA4 start your date range on the day the test went live. Nothing is counted twice: Varly only sends straight to the Google tag when there is no Tag Manager on the page.

Compare the versions in GA4

GA4 processes new data within a day or two, so give it time after launch.

  1. Register the parameter. In GA4, go to Admin → Custom definitions and create a custom dimension with scope Event and event parameter exp_variant_string. Do this once per property. GA4 only fills it from that moment on.
  2. Make a group per version. In Explore, create an exploration with a segment per version, for example users with the event experience_impression where exp_variant_string is VARLY-3f2b8c1e4a5d-b. Make one for the original (…-control) too. You can also save these as audiences.
  3. Compare. Put the segments side by side and add metrics such as purchases and purchase revenue.

Why GA4 can differ from Varly

The two never match exactly, and that is normal:

  • Consent. Varly only counts visitors who accepted cookies. GA4 may follow other consent settings, or estimate visitors who declined.
  • Ad blockers can block GA4, Varly or both.
  • Processing time. GA4 needs a day or two; Varly updates in real time.
  • Thresholds. GA4 can hide small numbers in reports to protect privacy.
  • Different counting. Varly counts each visitor once, in the version they saw first, with the orders your shop sends after that. GA4 counts its own purchase events.

See Why revenue numbers differ.

Common problems

Nothing arrives in GA4. Check that Send test data to GA4 isn't set to Don't send anything to GA4, and that a test is running. With Tag Manager, check that you imported the file and published the container.

There is no download link. Save your GA4 Measurement ID first.

"A GA4 Measurement ID looks like G-ABC123XYZ". You probably entered another ID, such as a Tag Manager ID (GTM-…). Copy the ID that starts with G-.

I can't pick exp_variant_string in my report. Register it as a custom dimension first, then wait for new data.

For developers

After the page has loaded, the snippet pushes the event varly_experiment with the parameters above to window.dataLayer (automatic and Tag Manager options). It calls gtag('event', 'experience_impression', …) only when window.gtag exists and, in automatic mode, no Tag Manager container is on the page; with a Measurement ID the call includes send_to. This happens at most once per browser session per test.

Was this article helpful?

Still stuck? Email support@varly.ai and we'll help you out.

Related articles