Title: Optimize code
Last modified: April 30, 2019

---

# Optimize code

 *  Resolved [alzie1](https://wordpress.org/support/users/alzie1/)
 * (@alzie1)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/)
 * Hi,
 * I am trying to install the Optimize codes in the plugin. I use Universal Analytics.
 * I add the following to Custom GA Code:
    ga(‘require’, ‘GTM-XXXXXXX’); with XXXXX
   being my container number.
 * I add the following to my Custom Code (anti flicker):
    <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>
 * I get the following error when doing dignostics:
    Errors Optimize plugin not 
   found The web page page doesn’t have Optimize plugin for the container ID (GTM-
   PNGBM63) installed. You can still use the visual editor to create variants but
   you can’t use Preview mode to test them and visitors won’t see your experiment.
   To run an experiment you must first install Optimize .
 * Warnings
    The anti-flicker snippet timed out The anti-flicker snippet might not
   have been configured correctly or the timeout value is too short. The anti-flicker
   timeout is a worst-case scenario. Your page will only be hidden for the full 
   timeout if the experiment cannot execute sooner (and when it does, the page is
   unhidden immediately). When anti-flicker times out, your experiment doesn’t run
   on that page load, which can limit the efficacy of your experiment and results.
   Regardless of timeout value, ensure that the Optimize plugin is deployed correctly
   and not late in the page (e.g. in the <BODY>).
 * What am I doing wrong?

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

 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11481959)
 * I’m not sure. You may want to ask your question in the Google help forum, or 
   try a different plugin would be my best advice for you.
 *  Thread Starter [alzie1](https://wordpress.org/support/users/alzie1/)
 * (@alzie1)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11483226)
 * No solution for this?
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11483340)
 * Honestly I do not know what you are trying to do. Perhaps if you could simplify
   your question I would be able to understand better and try to help.
 *  Thread Starter [alzie1](https://wordpress.org/support/users/alzie1/)
 * (@alzie1)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11483520)
 * I apologize.
 * So I just installed this plugin connect Google Analytics, but also to connect
   Google Optimize. I have followed the instructions and added GA Tracking ID and
   chosen the Universal tracking method. Google Analytics works fine.
 * However, I run into trouble when trying to connect to Google Optimize, as Google
   optimize gives me an error even after following this guide for Optimize:
    1. 
   I added ga(‘require’, ‘GTM-XXXXXX’); with my number instead of XXXXXX in the “
   Custom GA Code”-field. 2. I added the flicker code to “Custom Code”-field.
 * Anything I have done wrongly?
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11483994)
 * Thanks that helps. If you can provide a link to the Google doc you are looking
   at, I will take a closer look and let you know if/how it’s possible along with
   correct steps to implement.
 *  Thread Starter [alzie1](https://wordpress.org/support/users/alzie1/)
 * (@alzie1)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11484419)
 * Thanks Jeff, I really appreciate your help!
 * The guide I followed from your FAQ plugin page is under this question:
    “How 
   to implement Google Optimize?”
 * And in regards to the Google guide, it is on this page:
    [https://support.google.com/optimize/answer/6262084](https://support.google.com/optimize/answer/6262084)
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11485614)
 * Thanks. So I went thru and followed the Google doc steps, compared with the plugin/
   FAQ steps, and implemented on default WordPress. Everything looks good as far
   as I can tell. Remember that this plugin simply adds the correct code and nothing
   more; all of the Google stats stuff happens on their servers. So if you are getting
   errors in your Google account my best advice would be ask about it on the Google
   support forums, where someone should know best how to resolve any issue.
 *  Thread Starter [alzie1](https://wordpress.org/support/users/alzie1/)
 * (@alzie1)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11485653)
 * Thank you for going through the docs and setting it up. I will do that. Just 
   to make sure I didn’t miss anything, could you please share your backend plugin
   settings in a screenshot or similar? Would appreciate it hugely.
 * Thanks for the wonderful support!
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11485711)
 * Sure here is a [screenshot](https://perishablepress.com/share/google-analytics-optimize.jpg)
   of the GA settings. Let me know if I can provide any further infos, glad to help
   however possible.

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

The topic ‘Optimize code’ is closed to new replies.

 * ![](https://ps.w.org/ga-google-analytics/assets/icon-256x256.png?rev=2053004)
 * [GA Google Analytics – Connect Google Analytics to WordPress](https://wordpress.org/plugins/ga-google-analytics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ga-google-analytics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ga-google-analytics/)
 * [Active Topics](https://wordpress.org/support/plugin/ga-google-analytics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ga-google-analytics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ga-google-analytics/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/optimize-code/#post-11485711)
 * Status: resolved