Implementing Google Optimize

Essentially, there are three ways how you can implement Google Optimize to your website:

  • Directly (when you use Google Tag Manager)
  • Directly (when you do NOT use Google Tag Manager)
  • Indirectly — served by Google Tag Manager.

Regardless what method you choose, you can add Google Optimize only to pages where you intent to run experiments.

Let’s take a look little closer to all those options.

Direct implementation with GTM on-site

This is the recommended technique by Google.

According to Gogole, this method has the best performance (the lowest latency). It requires to modify your Analytics tracking code and make two changes:

  1. Add a specific Google Optimize line.
  2. Remove the line which fires GA hits (since you already send GA hits by GTM).

If needed, you make a third edit and that is adding a page hiding snippet which helps with minimizing page flickering.

Finally, you add the code to your source code, as high as possible in your page’s <HEAD> tag.

You can find the complete step-by-step guide at Optimize Help website.

Direct implementation without GTM on-site

In this technique, you will need to modify your existing Analytics code.

You can downlaod (copy) the modified Analyics code which includes the Optimize snippet at the Experiments page of Google Optimize website. Just click “Install Google Optimize” and it pops out.

Again, you can add page flickering snippet, and then add the code to your source code, as high as possible in your page’s <HEAD> tag.

You can find the complete step-by-step guide at Optimize Help website.

Google Optimize served by GTM

You can also serve Google Optimize by GTM.

It is probably the easiest technique. Nevertheless, it might result in increased latency. And there is one more important thing to consider.

When Optimize is served via Tag Manager, the GTM container must be loaded before the Optimize container. The result is that Optimize experiments only execute after both the Tag Manager and Optimize containers are loaded.

So you need to make sure your GTM container is as high in the source code as possible.

There is a ready-to-use tag type for Google Optimize so it is really easy to add it to GTM. You just need to fill out the GA settings, GO container ID and you’re ready to go.

You can find the complete step-by-step guide at Optimize Help website.


In my experience, implementing Google Optimize requires a little patience. You may need to try few options to find out which implementation method works for you and how best to setup the page hiding snippet.

It is good to bond with your developer and dig together into the implementation. Do a proper QA after it is done to make sure it’s working properly and the latency is low.