In principle, we recommend the use of Google Optimize for A/B tests.
Google recommends the following setup to integrate Google Optimize:
For the optimal order of integration of the different Google products like Google Analytics or Google Optimize, please read this Documentation from Google.
The optimal configuration is of course heavily dependent on the respective shop. We recommend that you discuss the optimal setting with your agency.