Getting Started with Google Optimize

Getting Started with Google Optimize
// Google Analytics, SEO, Social Media and PPC blog » Blog


A few months ago, Google announced that it would be offering a free version of Google Optimize 360 to the public. This month, people who requested an invite to Optimize will begin to receive access to the tool. If you have access, this article will help you get started. If you would like to sign up for Optimize, but have not requested an invite yet, you can do so here. Google is granting access on a first come first serve basis through early 2017.

What is Google Optimize?

Google Optimize 360 is Google’s A/B testing and personalization platform. Like most A/B testing platforms, it allows marketers to test variations of a site in order to improve conversions. Unlike most A/B testing platforms, it natively integrates with Google Analytics.

Google Optimize (free) vs Google Optimize 360

Google has a great comparison chart for what is included in each package. Here I will simply explain the limitations of the free version.

No audiences. Optimize 360 allows you to use Google Analytics audiences to target which users will be included in your experiment. The free version does not. If you are looking to make sure only relevant users see your experiment, you’ll need to use a combination of other targeting options Optimize offers.

Limited Concurrent Experiments. The number of concurrent tests you can run is capped at 3. This shouldn’t be a problem for small and medium sized sites that are just getting started with A/B testing. But larger, more experienced teams may find this to be a real handicap.

Limited multivariate testing. The free version of Optimize does offer multivariate testing, but multivariate tests are limited to 16 variations.

Pre-selected Objectives. One of the great features of Optimize 360 is the ability to see how an experiment would have impacted other GA goals by retroactively changing experiment objectives. It can do this because objectives are actually GA goals, which are pulled from the view you tied to the Optimize container.

How is Google Optimize Implemented?

Then. When it was first released, Optimize was implemented using a container similar to that of Google Tag Manager. This snippet of code was added immediately after the opening <head> element. Most A/B testing snippets are implemented after the opening head because it reduces the flash a users might see if the snippet is added lower on the page.

Now. Optimize can now be implemented through Tag Manager. You can use your current implementation of Tag Manager to do this. But, because Tag Manager was originally implemented immediately following the opening <body> element, it is recommended that you use the new Tag Manager implementation, which places the JavaScript portion of Tag Manager immediately after the opening <head> element, and the <noscript> portion of Tag Manager immediate following the opening <body> element. This allows the Optimize tag to be fired as soon as possible, eliminating the flicker effect.

What is the flicker effect?

The flicker effect, sometimes referred to as FOOC (flash of original content), happens when a user sees the page update with test changes. Here is the effect in action:

ab test flicker in action


What You’ll Need To Get Started

To get started you’ll need a Google Analytics account, you’ll need to make sure Universal Analytics is set up on your site, and you’ll need access to Optimize.

A Google Analytics Account. You probably already have an account, if not you can get one here.

Set up GA tracking for your site. We strongly recommend using Google Tag Manager for this. Tag Manager will allow you to easily add Universal Analytics and Optimize to all pages of your website. It will also allow you to track events (i.e. link clicks, form submissions, etc.). Optimize requires that you track events as GA goals before they can be used as experiment objectives, and the easiest way to track events is using tag manager.

In the past Tag Manager was implemented immediately following the opening body tag. With the release of Optimize, Google has updated the Tag Manager container so that it can be placed on immediately following the opening head element.

Optimize Access. If you haven’t requested an invite yet, you should do that now. Google will be granting people access over the next several months. Requesting an invite will add you to the end of the invite list. Google is not giving preferential treatment to partners or clients, so get in early and be patient.


Create an Account and Container

Once you have access to Optimize, you’ll be able to login and create an account. An account allows you to run experiments on one or more websites, you’ll likely only need one account per company. The container is where all of the configuration information for your experiments will live.

Click “Create Account” and you’ll be prompted to enter an account name and container name.

Account Name Best Practice. Use your company name (i.e. Acme Corporation).
Container Name Best Practice. Use the domain name of your website (i.e.


Link Google Optimize to Google Analytics

Next you’ll need to link Optimize to your analytics account and to one of the views in your account.

Clicking on a container from your accounts page, you’ll be taken to the Optimize container page. On the right hand side of this page you will see a 5 step process for completing the setup.

Click on “Link to Google Analytics” and then click “Link Property”. This will open a prompt which will allow you to link Optimize to one of your GA properties. Select the property you want to link to Optimize, then select one or more views to include.


View Selection is Important. The maximum number of goals the basic Google Analytics account can have is 20. And because Optimize requires events like link clicks be recorded as a GA goal, you’ll need to think about how many goals you’re currently using and what additional goals you’ll need to set up for testing.

If you are close to the maximum number of goals allowed by GA, and you know that you will need to set up additional tracking for testing purposes, then it might make sense for you to create a view specifically for testing.

Installing Optimize

Now that you’ve created an Optimize account and container, and linked your container to GA, you’ll need to install Optimize on your site.

Deploy Google Optimize with Google Analytics

When your Optimize container was created, it generated a container ID (GTM-XXXXXX). If you have Universal Analytics hard coded on each webpage, then you can install Optimize by adding a single line of code to your GA snippet. You can see this implementation in bold below.

<script> (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-123456-1', 'auto'); ga('require', 'GTM-XXXXXX'); ga('send', 'pageview'); </script>

With this implementation, it is recommended that you add the page hiding snippet to minimize page flicker. The following snippet should be placed immediately after the opening <head> element.

<style>.async-hide { opacity: 0 !important} </style> <script>(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.end=i=function(){ s.className=s.className.replace(RegExp(' ?'+y),'')};(a[n]=a[n]||[]).hide=h; setTimeout(function(){i();h.end=null},c);})(window,document.documentElement, 'async-hide','dataLayer',2000,{'GTM-XXXXXX':true,});</script>

Deploy with Tag Manager

If you are using Tag Manager, you can deploy Optimize using the Optimize Tag.

1. From your Tag Manager Workspace, click “New Tag”.

2. Click “Tag Configuration”.


3. Select the “Google Optimize” tag type.


4. Enter your GA Tracking ID and Optimize Container ID.


5. Click “Triggering” and choose or create a Page View Trigger that will fire the tag on the desired pages. This will likely be all pages.


6. Click “More Settings”, and configure the Fields to Set and Advanced Configuration with the same values as your Google Analytics tags.

7. Click “Save”.

Remember to test before publishing.

Creating Your First Experiment

Creating your first experiment is very simple.

1. From the Optimize Container page, click the blue “Create Experiment” button.


2. Enter your experiment name, editor page, and the type of experiment you would like to run. The editor page is the page you will make modifications to using the visual editor. For example, if you’re running and experiment on blog pages, enter one blog entry URL. Later you will use experiment targeting to apply your changes to some or all of your blog posts.


3. Select the type of experiment you would like to run. You have three basic options here:

  • A/B Test. Tests two or more variants of a page, also called an A/B/N test. This is the most common of the experiments.
  • Multivariate Test. Tests variants with two or more different sections on the same page (or page template). This is great for when you want to try multiple combinations of elements on the same page (or page template).
  • Redirect Test. Test separate web pages identified by different URLs or paths. If you’re making large changes to page code it can slow down the page. If you find yourself in that situation, it’s better to run a redirect test. Don’t forget to add a noindex tag to the test page.

Experiment Interface

For the rest of this blog post we will focus on an A/B test. Let’s dive into the experiment interface.

There are two main tabs, “Details” and “Reporting”. Details is where you’ll be able to find and modify experiment information, Reporting is where experiment data is reported (it’s also reported in GA).

There are two main sections here: variants and configuration.

Variants Section


Variants is where you’re able to see:

  1. How many variants are in your experiment
  2. What percentage of traffic each variant will receive (an even split is recommended)
  3. Options for previewing how the experiment will look on desktop and mobile. It is also where you can generate a preview link for your team.
  4. Number of changes made to the variation.
  5. Additional options which include edit variant name and delete variant.

Configuration Section


The configuration section is where you are able to provide a description of the experiment, select experiment goals (objectives), and select targeting parameters.

Selecting Objectives is Important. Unlike Optimize 360 (the premium version) you can not retroactively change objectives to see how your experiment affected other goals. So make sure you have all of your objectives selected before you start your experiment.

Hypothesis Best Practices. If you’re just getting started with testing, you may be tempted to simply write a description of test and skip the hypothesis. This is not recommended. Writing a clear hypothesis will keep you honest when the results roll in. Follow this basic formula when generating a hypothesis: If [I do this], then [this will happen].


The targeting section is where you will define what conditions will fire the experiment. Targeting options are evaluated on page load.

Targeting Options. Each targeting option links to the Optimize targeting docs which have much more information about how to use each of these options.

  • URLs. Target specific pages and sets of pages. URL targeting allows you to pick the web pages where your experiments run. URL targeting is useful for presenting experiment variants on a specific set of pages, easily defined by their URL. You can target a single page, a narrow subset of pages, or even Hosts and Paths.
  • Audiences (360 only). Target Audiences that you create in Google Analytics. Optimize 360 allows target your experiments to Analytics Audiences. This allows you to focus your experiment on a group of users who have exhibited specific behaviors on your site.
  • Behavior. Target users arriving to your site from a specific channel or source. Behavior targeting allows you to target first time users and visitors coming from a specific referrer.
  • Geo. Target visitors from a specific city, region, metro or country. Use Geo targeting to target users from a particular geographic area. For example, you might invite users from a specific city to attend an in-person event or to visit your retail location. While typing in the Values field, you’ll see suggestions from the AdWords Geographical Targeting API to help speed rule creation.
  • Technology. Target users visiting from a specific browser, operating system or device. Optimize looks at the browser’s user agent string to identify which browser is being used, what version, and on which operating system. You can use these data as targeting criteria in Optimize.
  • JavaScript Variable. Target pages based upon JavaScript variable values. Use this type of targeting if you can find the value you’re looking for in the source code of the webpage in the form of a JavaScript variable.
  • First-party cookie. Target the value of a first-party cookie in the visitor’s browser. Optimize can check to see if a visitor has a first-party cookie from your website and use that information in targeting rules.
  • Custom JavaScript. Target pages based upon a value returned by custom JavaScript. Custom JavaScript targeting allows you to inject JavaScript onto a page, then target your experiments based on the value that the JavaScript returns.
  • Query Parameter. Target specific pages and sets of pages. Optimize can check query parameters and use them in targeting rules.
  • Data Layer Variable. Instead of referencing JavaScript variables in your targeting conditions, you can reference key-value pairs that are stored in the data layer.

Match Types

Each targeting option has a variety of different match types.

  • Equals/Does Not Equal. Every character, from beginning to end, must be an exact match of the entered value for the condition to evaluate as true. Evaluate as true when the query parameter does not equal any of the entered values.
  • Contains/Does Not Contain. The contains match type (also known as a “substring match”) allows you to target any occurrence of a substring with a longer string.
  • Starts With/ Does Not Start With. The starts with match type matches identical characters starting from the beginning of the query string up to and including the last character in the string you specify.
  • Ends With/Does Not End With. An exact match of the entered value with the end of the URL. You can target shopping cart pages that use /thankyou.html at the end of their URLs.
  • REGEX Matches/Does Not REGEX Match. A regular expression uses special characters to enable wildcard and flexible matching. Regex matches are useful when the stem, trailing parameters, or both, can vary in the URLs for the same webpage. If a user could be coming from one of many subdomains, and your URLs use session identifiers, you could use a regular expression to define the constant element of your URL.

Free REGEX Book (PDF). If you’ve never used regular expressions, you’re missing out. They’re endlessly useful. LunaMetrics CEO Robbin Steif wrote a short book about using regular expressions for Google Analytics. It’s a great resource for those just starting out.

Editing Your Variation with Optimize Visual Editor

To use the Optimize Visual editor you will need Google Chrome the Google Chrome Optimize Extension.

Once you have downloaded the Optimize Extension, you can enter the visual editor by clicking on one of your variants. When the editor loads, you will see the editor page you defined when setting up the experiment. If you’ve ever used a WYSIWYG editor, this interface will be fairly intuitive. Point and click to select an element, drag and drop to move elements around, and use the blue slide up menu to modify an elements style. Below I provide details about the options available in this editor.


  1. Experiment Name. This is the name of your experiment.
  2. Toggle Variants. Displays a dropdown of variants, selecting one will load the variant into the editor.
  3. Device Testing. This dropdown menu displays stock devices to choose from. Selecting one of the devices will show you how your experiment will look on that device. Desktop is always selected by default.
  4. Number of Changes Made. Clicking on this element will open a menu that shows every change that was made to the current variant, and gives you options for editing or deleting each change.
  5. Diagnostics. This is a count of potential issues with the changes you made. These issues are also flagged in your list of changes.
  6. Custom CSS. If you prefer to working with code, this menu item will allow you to add custom CSS to variant. This is only applied to the variant you’re currently working on, not all variants.
  7. Interactive Mode. If you need to edit content that is hidden by a dropdown or tab, you will need to use interactive mode. Entering interactive mode will allow you click on elements to expose hidden content. You can then exit interactive mode to edit said content.
  8. Settings. There are two ways to drag and drop elements. The default is Reorder. Using the Reorder option
  9. CSS Element Selector. If you know how to use CSS selectors, you can use this feature drill into the DOM. This is the easiest way to do things like modify every <p> element on a page. One of our Analytics Engineers, Kristen Perko, talks about CSS selectors in her article about hover tracking.
  10. Element Hierarchy. This menu shows you how a selected element is nested in other HTML elements. You can use this menu to
  11. Selected Element. When selecting an element, it will be framed in blue. Once selected the blue tab at the top left of the frame will show you what element has been selected, and the element hierarchy bar will change to show you how that element is nested in the HTML. If you are having trouble selecting an element, get close enough with point and click, then use the element hierarchy navigation to traverse the page HTML. If you would like to select multiple elements of the same type, then use the CSS Element selector (#9).
  12. Modify Element Options. This dropdown is presented to you when you right click on the element you selected. The naming convention makes the options self-explanatory.
  13. CSS Editor. If you are not familiar with CSS, Optimize has an editor palette that makes changing styles simple. Just click, or use use the element hierarchy, to select the element you want to change. The CSS palette will populate with all of the styles of that element. Once selected you will be able to change the dimensions, location, font, text size, color, etc. or said element. Clicking on “Edit Element” will give you the same modifications options as right clicking on an element – remove, edit text, edit html, insert html, and run JavaScript.

Running Your Experiment

Once you have made your modifications, click “Save” and navigate back to experiment page. Double check your objectives and targeting options, the you’re ready to start your experiment.



It is recommended that you let an experiment run for at least two weeks before looking at results.

As your experiment runs, the first card of your reporting tab will populate with the current winner. Once enough data is collected, Google will declare a clear winner.


The second card on the reporting tab shows how each variation performed for each objective that you set.


The third and final card in your report will show you more granular data about each objective, as well as a nice performance graph.

  • Improvement – For a given objective, the difference in conversion rate, measured as a percentage, between the variant and the baseline.
  • Experiment Sessions – An experiment session is the period of time a user is active on your experiment. By default, if a user is inactive for 30 minutes or more, any future activity is attributed to a new session. Users who leave your site and return within 30 minutes are counted as part of the original session.
  • Probability to beat baseline – The probability that a given variant will result in a conversion rate better than the original’s conversion rate. Note that with an original and one variant, the variant’s Probability to Beat Baseline starts at 50 percent (which is just chance).
  • Probability to be best – The probability that a given variant performs better than all of the other variants. Because there can be only one “best,” the sum of all percentages in this column should equal 100 percent.


What’s Next?

So, you set up a test and you ran it. Now what? Iterate. The success or failure of your experiment has taught you something that you can use to run additional experiments. Think about different forms of testing, or different targeting options. Remember that who you test is just as, if not more, important than what you test. So note what you learned, note what questions came from your experiment, and begin thinking about what your next test would look like if you changed the offer or changed the people who saw the offer. Repeat.

The post Getting Started with Google Optimize appeared first on LunaMetrics.


Shared via my feedly newsfeed