Set up Google Optimize and Tag Manager

1. Head to the Google Optimize site and click one of the Start for free buttons.

2. Click Get Started and complete the onboarding process.

Google recommends opting into improving Google products, benchmarking, and in-depth analysis.

3. Accept all terms and conditions, then click on My Container in the Experiments view and copy your account and container ID.

4. Click on Settings, then the Link to Analytics button, select the view you’d like to link, and click on Link.

5. Open Google Tag Manager and create a new tag, select Google Optimize from Choose tag type, and enter your Google Optimize and Google Analytics ID.

6. Choose your triggering options, save, then preview and debug.

If you’re going to experiment on your entire site, you can go with All Pages, but you can choose whatever you’d like.

7. Copy the full code below and add it to every page with Optimize, as early as possible but after any dataLayer declaration.

.async-hide { opacity: 0 !important} (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; })(window,document.documentElement,'async-hide','dataLayer',4000, {'CONTAINER_ID':true}); Ensure that your Tag Manager container immediately follows the anti-flicker snippet. This creates a short delay in loading the page.