Autoptimize breaks Google Optimize
-
I recently implemented Google Optimize in the header.php of my website following the steps on the Lunametrics website.
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)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Autoptimize breaks Google Optimize’ is closed to new replies.