How To Install Google Optimize

Why Should I Install Google Optimize?

Google Optimize takes the guesswork out of website updates. Rather than jumping into new changes based on hunches, Optimize lets you test changes and show the hard data behind what site updates point users in the direction of your desired outcomes.

Optimize has some serious benefits:

  • Guides website updates to base decisions and changes on user actions and data
  • Direct integration with Google Analytics to tie your A/B tests to your main website goals
  • Easily identify user segments and audiences
  • Opportunity to upgrade to Optimize 360

But wait...there’s more.

Google Optimize integrates beautifully with the Google Marketing Platform, and when married with Google Ads, Google Tag Manager, and Google Analytics, Optimize is a vastly powerful tool. With the relationship between the Google Marketing Platform, Optimize makes it easy to install, experiment, and report.

If you’re wondering whether Google Optimize or Google Optimize 360 is right for your business needs, check this article to get a full breakdown before installing.

Google Optimize Installation Instructions

Installation with Google Tag Manager


In order to run experiments in Google Optimize, the Google Optimize code must be installed on your site on all pages. This only needs to be installed once, then most experiments can be set up within the interface. While there is a pre-baked Google Optimize tag in Google Tag Manager, Seer recommends to reduce page load latency by using the process laid out below.

Creating Your Optimize Account

If you do not already have a free Google Optimize Account, you can sign up for one for free or contact Seer for a premium Google Optimize 360 Account.

Order of On Page Tracking Code

These code elements should be placed as high in the page as possible to reduce latency. Tracking elements should be placed in this order:

  1. Any dataLayer snippets used for tracking or testing
  2. Page-hiding snippet
  3. GA code with Optimize, but no pageview
  4. Google Tag Manager container snippet

Page-Hiding Snippet

Seer recommends using the page-hiding snippet as it eliminates or reduces the risk of a page flicker. Install the page hiding snippet as high in the <HEAD> as possible but below dataLayer snippets and above the Google Tag Manager snippet already installed. Note that we are using the Optimize container ID in this snippet.

<!-- Page-hiding snippet (recommended)  -->

<style>.async-hide { opacity: 0 !important} </style>


(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, {'GTM-XXXXXX':true});


  • Again, note that “GTM-XXXXX” in this snippet will be your Optimize container ID, NOT a Google Tag Manager container ID.

capture 1

  • The Optimize Container ID can be found in the “Container setup” right sidebar in Google Optimize, highlighted with the red box above.

GA Code with Optimize

This initializes GA with Optimize, but does not fire a pageview, as that will be handled within Google Tag Manager. Note again that the container ID is for the Optimize container.

<!-- Modified Analytics tracking code with Optimize plugin →


(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','','ga');

ga('create', 'UA-XXXXXXX-X', 'auto'); ga('require', 'GTM-XXXXXX'); // Pageview call in GTM


Review and Verify

Have your team review and verify proper installation.

Link to Google Analytics

Link Google Optimize to your relevant Google Analytics property to reap the benefits of the linkage of the two:

  • Experiment result calculations
  • Access to Analytics goals and data to gauge result success in terms of already built Analytics data relevant to your business
  • Optimize 360 ONLY: Analytics audiences can receive targeted experiments


Google Analytics linkage function within “Container setup” right sidebar as highlighted above in the red box.

Ready, Set, Get Testing!

You’re all set to start running A/B, multivariate, and even personalization tests in Google Optimize. Need some ideas or want to dig further into this topic? Keep reading our blog posts:


We love helping marketers like you.

Sign up for our newsletter to receive updates and more: