Title: Autoptimize breaks Google Optimize
Last modified: August 3, 2018

---

# Autoptimize breaks Google Optimize

 *  Resolved [ingeklikt](https://wordpress.org/support/users/ingeklikt/)
 * (@ingeklikt)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/autoptimize-breaks-google-optimize/)
 * I recently implemented Google Optimize in the header.php of my website following
   the steps on [the Lunametrics website](http://w2QMJewSkP!8LL4X3fy^#tjR).
 * Unfortunately, Google Optimize didn’t work. I discovered that it does work when
   Autoptimize is turned off. Is there a way to exclude the Google Optimize code
   from Autoptimize?
 * This is the code that is written in the header.php file:
 *     ```
       <!-- Page hiding snippet (recommended)  -->
       <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),'')};
       (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
       })(window,document.documentElement,'async-hide','dataLayer',4000,
       {'GTM-XXXXXX':true});</script>
   
       <!-- end Optimize Page Hiding Snippet -->
   
   
       <!-- Analytics-Optimize Snippet -->
       <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','https://www.google-analytics.com/analytics.js','ga');
         ga('create', 'UA-XXXXXX', 'auto');
         ga('require', 'GTM-XXXXXX');
       </script>
   
       <!-- end Analytics-Optimize Snippet -->
       ```
   
 * I’d love to know if there is a solution since I really want to use both, thanks
   🙂

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/autoptimize-breaks-google-optimize/#post-10554231)
 * hey ingeklikt 🙂
 * as per [the FAQ](https://wordpress.org/plugins/autoptimize/#faq) you can either
   wrap the JS-code in “noptimize”-tags or you can add a string (e.g. `GTM-XXXXXX`
   but maybe not with those x’es 😉 ) from the inline JS to the comma-separated 
   JS optimization exclusion list.
 * hope this helps,
    frank
 *  Thread Starter [ingeklikt](https://wordpress.org/support/users/ingeklikt/)
 * (@ingeklikt)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/autoptimize-breaks-google-optimize/#post-10554289)
 * Wow Frank, that was a really easy and simple solution. Thanks a lot it works 
   🙂
 * -Marloes
    -  This reply was modified 7 years, 10 months ago by [ingeklikt](https://wordpress.org/support/users/ingeklikt/).
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/autoptimize-breaks-google-optimize/#post-10554330)
 * Graag gedaan Marloes, feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/autoptimize/reviews/#new-post)!
   🙂
 * groetjes uit het (te?) zonnige België!
    frank

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Autoptimize breaks Google Optimize’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

## Tags

 * [google optimize](https://wordpress.org/support/topic-tag/google-optimize/)

 * 3 replies
 * 2 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/autoptimize-breaks-google-optimize/#post-10554330)
 * Status: resolved