How can I do A/B testing in Google Analytics?
The Google Analytics interface offers the option of running experiments. To do so, first, configure the experiment in the Google Analytics interface (see how to do so here.; then add the code for the experiment to the site’s pages.
However, this is not the preferred way to run A/B tests now. In 2017, Google made Google Optimize free for use by everyone (https://analytics.googleblog.com/2017/03/this-is-not-a-test-google-optimize-now-free-for-everyone.html). Google Optimize (https://optimize.google.com/) is a much more advanced and easy-to-use tool for running A/B tests. It is integrated with Google Analytics and can be implemented with Google Tag Manager (though there are some limitations—see here. Although implementing Google Optimize from Google Tag Manager is not recommended, there is a standard tag for it in Google Tag Manager, and this is the fastest and easiest way to start using Google Optimize if you already have Google Tag Manager installed.
Google Optimize allows you to create different kinds of experiments to test your hypothesis. Learn how to set up experiments here.