Google Analytics 4 (GA4) officially launched in October after a long beta testing period. It is a completely rebuilt version of Google Analytics (GA) and independent of the previous Universal Analytics (UA) version. It has a separate web interface and distinct data collection. At that launch, GA4 did not have all the features of the UA version and the reporting system was not as user friendly. The product continues to evolve with improvements, new features and the addition of features that were available in UA. One of these missing features is now available as a beta: the ability to connect Google Analytics 4 with Google Optimize. This allows you to collect Optimize data within GA4 as well as use GA4 data to target which users will see the Optimize experiences.

Google Optimize is a tool that allows you to show different variants of a page to different users. These customizations are called experiences and they fall into three types:

  • Tests
  • Personalizations
  • Banners

Tests allow you to show different variants to determine which performs better against a metric such as increased purchases or more leads submitted. The types of tests are:

  • A/B (e.g. comparing two different text labels for a button)
  • Multivariate (e.g. testing two headlines and two photos in all combinations)
  • Redirect (e.g. comparing two different landing pages)

You typically need thousands of visits to get meaningful data from one of these experiments. With GA4, Optimize tests can currently run for up to 35 days, which will likely increase in the future (the UA instance permits 90 days). The following screenshot is of an Optimize page to set up an experiment.

Of the other experiences:

  • Personalizations allow you target certain customizations to a subset of users (e.g. those who have bought from your site in the last month).
  • Banners are messages shown at the top of all pages or only certain pages that you can limit to certain audiences or show to everyone.

This Google documentation compares Optimize linked with UA versus GA4. Differences include:

  • The ability to target experiments using data from GA audiences or Google Ads will be available for all users using Optimize with GA4. For Optimize with UA, these are only available for organizations using the paid Optimize 360 version of the product meant for enterprise sites.
  • With GA4, you are able to run up to 10 simultaneous experiments and 10 simultaneous personalizations per property.
  • You can optimize against purchases, purchase revenue, pageviews or any of the conversions that you’ve set up in GA4.
  • UA reporting was based on sessions while in GA4 reporting is based on users across multiple sessions.

To use Optimize with GA4, you need to create a new Optimize container and link it to the GA4 property. You then need to add the Optimize script for that container to the site’s page (at the top of the <head in the HTML). At the moment, it appears that you can only add the Optimize script directly to the page and not through Google Tag Manager (GTM) like you can with the UA version. If you are using both UA and GA4 on a site, you’ll need to determine which one you want to use Optimize with as using two different Optimize containers on the same page would almost certainly lead to conflicts.

Once you have an experiment running, you will now see a new GA4 event experiment_impression when you load a page. There are two parameters experiment_id (e.g. Ua9KAewoQVWwzFH5Kehqiw) and variant_id (e.g. Ua9KAewoQVWwzFH5Kehqiw.1) that are sent with the event. The decimal of the variant_id matches up to the variants of the experiment so “.0” is the original while “.1” is the first variant. You can then use this variant_id parameter to create segments to pull out the different audiences. Based on testing by AnalyticsMania, you’ll need to register these parameters as custom dimensions as they are not yet appearing automatically. Watch their video to see a demo of setting up Optimize with GA4 and several current limitations in the beta.