A/B Testing with Google Optimise

Download as word doc with images




Need Google Analytics & Google Tag Manager set up

Also need to use Chrome and add the Google Optimise extension.


  • Log into / set up Google Optimize
  • You are only allowed 1 container for 1 account
  • The ID of the optimise container, has nothing to do with Google T.M, although it confusingly, has a GTM prefix
  • Link to GA in the menu on the right


  • Get the snippet code – you can add the extra line of code manually to your GA code (that you probably already have on the site)
    or you can do it through GTM















To add the code via GTM

Login to GTM


Click Add New Tag


Choose the Google optimise Tag type


Add Google Analytics ID (or choose the variable if you’ve set it up)

Then add the Optimise Container ID (see red arrow in previous screenshot)























Name the tag


Click the box / icon below to choose a Trigger


Choose “All Pages” as the trigger* (assuming this is set up already)


*See this blog post for more info on setting up triggers – https://www.simoahava.com/analytics/trigger-guide-google-tag-manager/




The 2nd snippet of code prevents any ‘flickers’ of the default page (sometimes people might see both the A (for a moment) and then the B in the A/B test)



This code doesn’t work via GTM – as GTM loads code ‘asynchronously’ – which defeats the object



To make sure it loads first – ask a developer to add it to the <head> of the theme header


Or in WordPress – go to Appearance>Editor>Theme Header (header.php)

And paste the code just below the opening <head> tag




Back in Google Optimize


Click New Experiment button


Choose either A/B Test or Multivariate test



Now click +New Variant















Give the variant a relevant name – e.g. “Green Button”

Click Add


Next click the arrow and “Go to Editor” (see arrow below) (need extension on Chrome)


When you click to Go to Enter – you should be taken to your website and have the ability to edit the HTML etc on there





Click Save on top right of editor screen to Save variation


Now enter Objectives – which relate to goals in Google Analytics

Save and Click Start