How to install Google Optimize?

Incorrectly installing Google Optimize can lead to flickering, invalid test results, and many more bugs! In this guide, you will learn how to install Google Optimize the right way!

Google Optimize is installed by adding a small piece of code to your website. This code ensures that your users can see the different A/B tests you set up in Google Optimize.

There are a few different ways of installing Google Optimize. The best way to install your Google Optimize setup depends on your situation.

In order to find the right one, we need to make two choices:

  1. Do you want to use an asynchronous or synchronous snippet?
  2. Do you want to install Google Optimize via Google Tag Manager or manually?

What is the difference between asynchronous and synchronous?

A synchronous snippet will block other scripts from executing until it’s done loading. This makes sure that more people will be eligible for your experiments. The downside is that this blocking will cause your pages to load slower.

The asynchronous snippet will not affect other scripts on your website. This makes sure that the page speed remains fast. The downside of this implementation is that fewer people will be eligible for your experiments.

Be mindful of this choice while setting up experiments with Google Optimize because it may affect your results.

What is the difference between Google Tag Manager and manual implementation?

Google strongly recommends using the manual installation method, as it offers the best performance and is the easiest way to install Optimize.

In order to manually install Google Optimize you will need to meet the following prerequisites:

  • Access and ability to edit website source code
  • Google Analytics account
  • Google Analytics 4 property
  • Google Analytics 4 property connected to a website

The Google Tag Manager implementation is an alternative for those that don’t meet the prerequisites for manual implementation.

This method has its own prerequisites:

  • Google Analytics account
  • Google Analytics 4 property
  • Google Analytics 4 property connected to the website via tag manager
  • Google Tag Manager account
  • Google Tag manager container connected to your website

Once you have made your choices you can move on to the next step. Linking Google Optimize to your Google Analytics 4 property.

Start by going to

Here you can simply log in using your Google account that has access to the Google Analytics property.

Then click the blue create account button.

Usually, every account is attached to one website.

So you could use the name of the website that you are applying it.

Then choose if you want to share your data with Google by checking or unchecking all the boxes.

Then choose your country.

And accept the terms of service by checking all the boxes.

Then click next in the top right of the pop-up window.

Then we will have the set the container name.

I like to use my domain name.

Then click on the create button.

Once your property is created you need to go to settings.

Then you need to find the measurement section and click the link to the analytics button.

Here you should be able to select your Google Analytics property that is connected to the website you want to test on.

You have the option to choose a GA4 or universal analytics property. Since universal analytics will be discontinued in 2023 I recommend choosing GA4.

Then you have to select the GA4 stream you want to use. Usually, a stream will be a specific website or application. So choose the one you want to run experiments on.

Now you have successfully linked your Google Analytics property to your Google Optimize container.

The next section is about manually installing Google Optimize. The section after that will be about installing Google Optimize with Google Tag manager.

How to install Google Optimize manually?

In order to install Google Optimize on a website we need to insert a small snippet. We can find this snippet by going to your container and clicking settings.

A tab will open that includes a snippet that connects to your container.

The default state of this script will be synchronous.

<script src=""></script>

If you want to make it asynchronous you will need to add the async attribute to the script tag.

<script async src=""></script>

We will need to insert this snippet to the top of the <head> tag on every page you want to run your test.

The way of doing that will be different for most websites. So let’s focus on what the result should be.

If you right-click on your website you can inspect it.

On the right side of the website, you will see the code.

In the code search bar look for the <head> tag. The head tag will be marked with a green selection.

The snippet needs to be inserted into this head tag on the same level as the meta tags.

It’s best to place it as high as possible so it’s the first thing that loads.

The next section is about installing Google Optimize with Google Tag Manager. If you installed it manually you can skip this section.

How to install Google Optimize with Google Tag Manager?

Open up Google Tag Manager and click on tags.

Click on new.

Click on tag configuration.

Select Google Optimize as the tag type.

You will need to add your Optimize Container ID.

You can find it on the Google Optimize container dashboard. Choose the one that is connected to your site.

Copy and paste it into the field.

Click save.

 Save the tag without any triggers.

Click on your Google Analytics GA4 Configuration tag.

Click on tag configuration.

Click on advanced settings.

Then click on tag sequencing.

Click on the box to fire a tag before your tag fires.

Click on the dropdown.

Choose your Google Optimize tag.

Then click save.

Open up your Google Optimize tag and click tag configuration.

Click advanced settings.

Click the tag firing options dropdown and choose once per page.

Then save your tag.

Publish your container in order to test the installation.

In the next section, we will look at validating your manual or Google Tag Manager installation.

How to validate your Google Optimize installation?

Before we can validate our installation we need to install the Google Optimize extension.

Go to Google Optimize and click on your container.

Click settings.

Click install extension.

Click view extension.

Then install the extension.

In order to check the installation we need to make a quick personalization.

Click create experience on the container dashboard.

Click personalization.

Name the personalization anything you want. You will delete it later.

Then click create.

Scroll down and click check installation.

If you see the following screen you have made a mistake. I forgot to publish the GTM container.

If your installation was successful you will see this screen.

Congratulations! You have finished all the steps and are ready to start experimenting with Google Optimize.