Has anyone implemented Google Optimize correctly?

Shopify Partner
4 0 3

I subscribed to the beta testing of Google Optimize (optimize.google.com), and I was very curious to run the first test, but I couldn't manage to implement the snippets correctly.

Checking the source code, the GTM tag needed is shown correctly, but somehow it's not recognized by the Google Optimize app. I suspect that the way Shopify handles the Google Analytics snippet might have to do with this, but on the other hand I wonder: if I just paste the whole GA code in the <head> instead of using the option in the Settings, does that impact tracking at checkout?


New Member
1 0 1

Yes I have implemented google optimization correctly. Currently i optimized tour website and keyword is viajes a india you can follow.

Shopify Partner
4 0 3


I'm not talking about SEO (are you talking about SEO?), but about Google Optimize, a new A/B testing platform by Google.


New Member
2 0 0

Were you able to get it?

I am at this point now as well and would like to get it working.




Place the first line of code in the additional Google Analytics code in your online store preferences. The line will look like:

ga('require', 'GTM-XXXXXXX');

Paste the following in your theme.liquid file after the tag so that it loads before the analytics code. Replace GTM-XXXXXX with your code:

<style>.async-hide { opacity: 0 !important} </style>
<script>(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),'')};

Follow the remaining steps as usual.

Run Google Shopping ads? Get the free definitive guide to Google Shopping for Shopify (no optin required): https://www.digitaldarts.com.au/google-shopping
New Member
13 0 0

Very informative! One of the reasons i love this forum, i am constantly learning!

Shopify Partner
1 0 2

I've installed Google Optimize using Google Tag Manager and it worked flawlessly.

I am guessing that you have already done all the steps on the list, other than the adding the code to the page.

I have implemented the code for Optimize using Google Tag Manager built in tag for Optimize. All you need to do is:

1. Create a new tag in Google Tag Manager

2. Select Google Optimize tag from the list that pops up.

3. Insert Google Analytics Id and Optimize Id numbers in the fields.

4. Select all pages trigger

5. Create another new tag and select Custom HTML tag type

6. Copy hiding snippet from Google Optimize instructions Step 2

7. Change the number in the last line of code from the existing one to the ID number  of your Google Tag Manager account for the property where you are installing Optimize. This ensures that hiding snippet is as high as Tag Manager snippet.

Of course, this method is the only one that is available for those of you who have followed Google recommendation to install analytics snippet using Tag Manager. If that is the case you may have no other option to install Optimize. 

More detailed instructions (with pictures) are available in the blog post I wrote, Google Optimize: A First Look.

I hope this works for you.

New Member
2 0 0

I followed your instructions and got it to work, however I had two issues:

1. Could not get rid of the page flicker even after inserting the code.

2. Google Analytics stopped working. I have possibly got this working again.

Do you have any suggestions? Would love to get this working.




I've just checked your website and don't see Google Tag Manager code added. In the page source it's available, so I'm wondering how did you added it? I'm curious because working with GTM and Google Optimize. Both works fine for me now and have been doing testing with connection to Google Analytics via the tab "Experiments".

My integration Google Tag Manger and Google Optimize.

❤️ Found my answer helpful? Please LIKE or Accept Solutions.
❤️Top 30 Best Shopify Themes Free + Premium: A Complete Review Read More
New Member
2 0 0

I stupidly forgot to start the experiment - Duh! which is why you didn't see it. I have started the experiment now.

I am getting the page flicker which I've decided to live with since I don't know to fix it - help!

I am not sure about the Analytics piece. It appears (according to tag manager) that analytics turns off for the variant page but stays on for the control page. I'll run for the day and see how things go.

Open to feedback.