Here Google explains how to get the Google Optimize variant and change your page accordingly using gtag.

What I need to do is to be able to set the variant number for a specific experiment with Javascript (as early as possible in the page). And then the the page variant is shown and analytics data measures the variant I've set previously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.