How to setup and install Google Optimize

By | November 21, 2019

31 thoughts on “How to setup and install Google Optimize

  1. José Gómez Post author

    wow, Julian, excellent explanation , I am the admirer of all your videos, you can make a referete to the insertion of tracking codes to be able to see in Google analytics the transactions, the products added and deleted in the shopping cart, form of payment selected for the client? Is it possible that you could give us a video like that? Greetings from Venezuela.

  2. Giorgio Post author

    Hi Julian, I wonder if you could clear something up about deploying optimize via gtag.js. I'm deploying my Google Analytics PageView tag via Tag Manager. In the old analytics code, you deleted the PageView line to avoid duplicating data but in this scenario, I don't see that option with gtag.js. Does this mean I have to stop deploying my PageView via GTM?

  3. Илья Цветков Post author

    Спасибо за видео.привет с Украины💪

  4. Szabolcs Szőcs-T. Post author

    Hi Julian,
    If I'm using GTM wp plugin from Thomas Geiger, what is the process to install optimize?

  5. Ad Casey Post author

    Hi Julian, we have our GA Analytics.js tracking script installed via Google Tag Manager (GA premade template) on our Magento V1 site. The GTM container currently sits at the top of our <body> section due to the Magento GTM plugin we have used. It seems from the instruction in your video above that it might not work for our current setup? Please can you advise on the correct setup?

  6. Get Found Madison Post author

    Thanks so much! You continue to be the go-to resource for all things analytics.

  7. Bman Q Post author

    Julian hi,

    I am big fan of your videos!

    Could you compare 2 approaches to A/B testing you covered?
    1st – How to A/B Test with Google Tag Manager
    2nd – Google Optimize Tutorial 2017

    In first you were using GTM + thenextweb script + google analytics,
    in second you were using GTM + Google Optimize

    Which one is better solutions?
    What are the cons and pros of each?

  8. Predrag Pjanovic Post author

    Hi Julian,

    Great video, but i have little problem.

    If dataLayer is not defined as array "var dataLayer = []", but as "var dataLayer = {}" google optimize tag will not be loaded.

    I am not able to change dataLayer to be array since we are using it for another analytics that requires ordinary js object.

    Do you have idea how could i fix this?

    Is there a way to specify in the ga tracking code what dataLayer to use? I would define another one as js array object.

    Thank you in advance.

  9. Jørgen Wolf Post author

    Thanks a lot for sharing. Very well explained and to the point!

  10. Sam Samo Post author


    if I want to rank for a keyword with city, let's say for example: "mobile repair in city A", then I make other landingpage and optimize for the keyword "mobile repair in city B" and then agian other landingpage and optimize for the keyword "mobile repair in city C" and so on. is that good or it will harm the general keyword "mobile repair"


  11. Enzo G Post author

    Hi how can i add the optimize code so that anomize ip is still working?

    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'UA-112140713-xx', { 'anonymize_ip': true });

    Here the Optimize Tag:

    how do i implement this into the code above?
    gtag('config', '112140713-xx', { 'optimize_id': 'GTM-XXX'});

    thank you

  12. Randika Rodrigo Post author

    Awesome. Thank you for this!

    Is it normal for the tag assistant extension to show multiple GA Analytics and multiple Tag Manger ID's when the website has loaded with Google Optimizer? Even in your video when you view the site with optimizer, I see that it shows #6 in the tag assistant?

  13. Anna Loong Post author

    Hi thanks for the help, quick question in Google Optimize can you change the header image? if so how would you go about on that?

  14. Manish Singh Post author

    Hi Julian! Thanks for all the insights. I want to know whether Google analytics audience can be used into google optimize for personalization?

  15. Frank Pereira Post author

    Question we had this set up and what happens it goes to a black screen then the site loads. i deleted the script and deactivated for this reason. any way to fix this?

  16. Idan d Post author

    What is the best practice if I use GTM and my Analytics is already migrated to gtag.js?

  17. Michael Bae Post author

    Hey Julian,

    What if GA is set up through GTM? How can I edit the GA set up so that I can put the Optimize container ID inside?
    Do I have to remove it from GTM and set up GA manually on the site as well?



  18. Oshri Maidanik Post author

    Hi @Julian I have analytics gtag.js implement via native shopify and tag manager as well. how would you recommend to add optimize?
    after optimize-ga linking, optimize generates a new code: gtag('config', 'UA-13XXXXXX-X', { 'optimize_id': 'GTM-XXXXX3'});

    But the native shopify integration takes only the UA part.

  19. Jean-Florent BAUCHER Post author

    Just fine Julian. The alternative of GTM works fine with no negative impact on speed.

  20. Thomas Nordén Post author

    Is it still not recommended to use GTM to install Optimize?

  21. Peak District SEO* Post author

    I thought this video was good but the explanation became overly complex. Why not just make separate videos for each set up? An Analytics, and a GTM video

  22. Marcin K Post author

    Hi Julian, I've been watching your videos and appreciate all your input.

    I am having a problem though. I'm using the recent Global Site Tag (gtag.js) code and there is no visible "send, pageview" code for me to remove. When I try to copy the code provided, it doesn't appear to be installed. Sidenote: I too am using GTM4WP.

    <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=""></script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'UA-XXX-1', { 'optimize_id': 'GTM-XXX'});

  23. Mr Upgradable Post author

    This is exactly what I needed, thank you for the in-depth information and explaining the different configuration methods for example, for tag manager.

  24. Max Schurer Post author

    Hi there Julian,

    I have Google Analytics loading through Tag Manager and I want to keep it that way. How to install Google Optimize through Analytics gtag without loading Analytics twice? Thnx

  25. Paul Hampton Post author

    Thanks for the video. Still looking to setup an experiment correctly for our logged in users which after a user logs in the url is unique. All of our attempts at this have failed. Seems like this tool works really well on basic non-authenticated (non-unique url) pages. Basically when we have adjusted content on pages behind the login and then try to run them it runs and because we used a specific account for setting up the account it wants to load just that url which breaks the experience for the user and logs them out

  26. Arman Post author

    I dont get it, didnt you say you can implement tag priority in tag manager? I implemented it through google tag manager both the optimize and hiding snippet , I think it's easier for me who doesn't know nothing about coding.

  27. florian schoel Post author

    Hi Julien, thanks for your great content.

    Tricky situation here.
    1. We are using a Analytics Plugin in our shop for Enhanced Ecom Tracking.
    It uses the gtag Analytics Tracking Tag.

    2. The Plugin does not give us the option to put the Optimize ID into the script.
    Optimize and gtag Question.
    –> this will not work for us … (reason below):
    gtag('config', 'GA_TRACKING_ID', { 'optimize_id': 'OPT_CONTAINER_ID'});

    for the following reason:
    We are running a Google Analytics Tracking Plugin in our shop that already places
    gtag('config', 'GA_TRACKING_ID');
    in the header.
    –> The Plugin will not give me the option to add the "optimize_id" to the script

    Question 1:
    How do I add the ("optimize_id": 'GTM-XXXXXX') part manually when using GTAG and not having the option to put it in the "config" part?

    Question 2:
    Can this "optimize_id" Part be called before the config part?
    Or does it have to be called after the config part?

    Question 3:
    Do you know of a plugin for each of the following systems that already allows for input of the Optimize-ID directly into the tracking-code through the Plugin?

    Lots of questions.
    But besides me, i dont know anyone who would be able to answer those questions – other than you 🙂
    And I am out of answers.

    None of this is helpful by the way:


Leave a Reply

Your email address will not be published. Required fields are marked *