Starting July 1, 2023, Google Analytics has shifted from Universal Analytics (UA) to Google Analytics 4 (GA4). As GA4 supports custom dimensions, metrics, and offline tracking, businesses still on UA need to make this transition to benefit from enhanced tracking capabilities, including Magento 2 A/B testing.
Useful Tip: before starting Magento test, make sure that your website has a good loading speed. Magento 2 A/B testing tools can slow down your store creating an additional burden in loading. To avoid issues with speed loading, we recommend implementing the Google Page Speed Optimizer extension before running a/b tests. This plugin optimizes the HTML code, reduces the number of requests to the server by merging and minifying CSS and JS files, resizes images without losing the quality and allows you to enable the lazy loading.
Step 2. Navigate to Stores > Settings > Configuration > Sales > Google API. Expand the Google Analytics 4 section and set enable to "Yes. Enter your Measurement ID. Enable Content Experiments for A/B testing to support Google Analytics Content Experiments.
Step 1. Go to your GA4 property and select the appropriate Account and Property.
Step 2. Navigate to the Admin section, and either select an existing view or create a new one. To create a view, click Create View in the View column, choose either Website or Mobile app, give it a descriptive name, set the time zone, and click Create View.
Step 3. In the Behavior tab, go to Experiments and click Create experiment. Specify the traffic percentage, add the Original Page URL and the URLs of each variation, and complete the setup options. Once the experiment is set, select Manually Insert the Code and copy the snippet to use in Magento.
For more on how to do A/B testing with Google Analytics, refer to Google's developer documentation for detailed guidance.
Login and Registration Form