Autoptimize breaks Google Analytics

Bug #578713 reported by Rance Lucifinil
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Autoptimize
Fix Released
Undecided
Unassigned

Bug Description

I tried your Autoptimize plugin for wordpress. blog.iobit.com

Once I installed your plugin, it really worked, increased speed for opening my pages.

However, since then, there is no Google Analytics data any more!

two hours later, I found this issue, so I deleted your plugin at background.

2 hours later again, there is still no analytics data. I entered my server, found that there are some files of Autoptimize still there under cache folder. Then I deleted this folder completely.

1 hour later again, there is till no analytics data. I don't know where I didn't delete.

During these period, I didn't edit any code of my blog, just installed and uninstalled your plugin.

Is there anyway you can make my blog google analytics normal?

I have already deleted Autoptimize files at background and cache folder at wp-content/

Many thanks

--
Leonard Lambo
GM Department

IObit.com
Http://blog.iobit.com

Tel:+86-13402886117
Email:<email address hidden>

Emilio (turl)
security vulnerability: yes → no
visibility: private → public
summary: - Big Bug of your Autoptimize - need quick reply
+ Autoptimize breaks Google Analytics
Revision history for this message
Emilio (turl) wrote :

Please, don't mark bugs as security vulnerabilities when they aren't :) They just upset me :P

Now, I use Analytics on my own blog and never had any problems with autoptimize. It might just be Google being slow on processing data, who knows. If you want to disable autoptimize, just disable the JS compression on the options page, or the whole plugin if you prefer, just like you would do with any other plugin. If you use something like WP Super Cache, you might need to clean its cache and your browser's cache to restore the page to the state it was before using autoptimize.

As regards investigating this issue further, I would appreciate if you could attach here the source code of an autoptimized page of your blog, and all the files on the wp-content/cache/autoptimize/ folder, preferably zipped.

Looking forward to hearing from you

Changed in autoptimize:
status: New → Incomplete
Revision history for this message
Rance Lucifinil (lambo) wrote : Re: [Bug 578713] Re: Autoptimize breaks Google Analytics
Download full text (3.3 KiB)

I am sorry that I don't know about security category.

I have several Google Analytics monitors on this account. When I met that
problem, other google analytics are normal, except the one I used to monitor
blog.iobit.com, and this domain is the right one which just installed
autopimize.

And now everything changes into normal, the google analytics data for
blog.iobit.com turns well again about 6 hours later, but during these 6
hours, there was no data at all.

Before I got your email, I have deleted all files of autopimize and deleted
cache folder completely. So I am sorry that I can't send you that, because I
have no either.

However, maybe my personal blog will use and test your plugin, it really
increases the speed of wordpress. Good work, but I strongly suggest you to
find if there is a problem that against Google analytics codes.

2010/5/12 Emilio <email address hidden>

> Please, don't mark bugs as security vulnerabilities when they aren't :)
> They just upset me :P
>
> Now, I use Analytics on my own blog and never had any problems with
> autoptimize. It might just be Google being slow on processing data, who
> knows. If you want to disable autoptimize, just disable the JS
> compression on the options page, or the whole plugin if you prefer, just
> like you would do with any other plugin. If you use something like WP
> Super Cache, you might need to clean its cache and your browser's cache
> to restore the page to the state it was before using autoptimize.
>
> As regards investigating this issue further, I would appreciate if you
> could attach here the source code of an autoptimized page of your blog,
> and all the files on the wp-content/cache/autoptimize/ folder,
> preferably zipped.
>
> Looking forward to hearing from you
>
> ** Changed in: autoptimize
> Status: New => Incomplete
>
> --
> Autoptimize breaks Google Analytics
> https://bugs.launchpad.net/bugs/578713
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Autoptimize: Incomplete
>
> Bug description:
> I tried your Autoptimize plugin for wordpress. blog.iobit.com
>
> Once I installed your plugin, it really worked, increased speed for opening
> my pages.
>
> However, since then, there is no Google Analytics data any more!
>
> two hours later, I found this issue, so I deleted your plugin at
> background.
>
> 2 hours later again, there is still no analytics data. I entered my server,
> found that there are some files of Autoptimize still there under cache
> folder. Then I deleted this folder completely.
>
> 1 hour later again, there is till no analytics data. I don't know where I
> didn't delete.
>
> During these period, I didn't edit any code of my blog, just installed and
> uninstalled your plugin.
>
> Is there anyway you can make my blog google analytics normal?
>
> I have already deleted Autoptimize files at background and cache folder at
> wp-content/
>
> Many thanks
>
> --
> Leonard Lambo
> GM Department
>
> IObit.com
> Http://blog.iobit.com
>
> Tel:+86-13402886117
> Email:<email address hidden> <Email%<email address hidden>>
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/autoptimize/+bug/578713/+subscr...

Read more...

Revision history for this message
Emilio (turl) wrote :

Good to hear everything is back to normal :)

One odd thing I noticed on your site is that you have your analytics code misplaced, it should go near the end of the page (just before </body>), but you have it near the header of the page (just after <body>). Maybe this is what makes autoptimize break Analytics?

I've marked this bug as invalid as you won't be able to provide the information needed to look into this further, but if you ever experience this again (maybe on your personal blog?) feel free to reopen the bug and attach/send the mentioned data.

By the way, you might want to try the 'try-catch wrapping' option Autoptimize has and see if that 'unbreaks' analytics.

Changed in autoptimize:
status: Incomplete → Invalid
Revision history for this message
Andy Beard (list-andy) wrote :

Could this be related to some plugins recently switching to async

I lost a few days data (from May 8th) as I don't live in Analytics, or even log into my blog every day at the moment.

I was using Google Analyticator combined with some other plugins for testing. I ripped them all out and added raw analytics code using header & footer, and it works fine with no issues.
I can't remember whether I updated a plugin around that time, either autoptimize or Analyticator... but it is quite possible I updated both.

I don't like placing blame on things like this, just look for solutions, and the interaction between these plugins looks to be the problem.

To be honest GA code is the one item I would prefer is left as it is, exactly as it gets inserted into the page, including any modifications.I know it is hard to allow for this, but it is impossible to diagnose something that isn't working.

Revision history for this message
Ben Palmer (ben-graphnetwork) wrote :

Hi Emilio,

I am having a similar problem with google too at take5japan.com

Your plugin is great, but since turning it on, google analytics has stopped reporting.
I've tested it over 4 days, and the reports stop when the javascript optimizer option is switched on.

I was wondering if there is a quick way, to tell the plugin to ignore the google javascript file?
I am currently seeing if your try-catch advice works, but was hoping also for a easy way just to have autoptimize exclude a javascript file.

I have tried this with the wp google analytics plugin and also just hardcoding the google script into the footer, but the outcome is the same.

Any advice would be great,
Thanks.

Ben.

Revision history for this message
Rance Lucifinil (lambo) wrote :

Hi Ben,

I am quite sorry that I didn't take any more test about this problem.

Because I am taking charge in my company's website, I dare not to test on
company sites, and my personal website needs no google analytics, (cause it
is my private blog, I just record something important for me, there is
little traffic).

However, Since Google changed a new tracking code, adding it into <head>, so
I don't know if this problem exsits or not. Maybe I will try later for other
websites(I need to find one)

2010/6/14 Ben Palmer <email address hidden>

> Hi Emilio,
>
> I am having a similar problem with google too at take5japan.com
>
> Your plugin is great, but since turning it on, google analytics has stopped
> reporting.
> I've tested it over 4 days, and the reports stop when the javascript
> optimizer option is switched on.
>
> I was wondering if there is a quick way, to tell the plugin to ignore the
> google javascript file?
> I am currently seeing if your try-catch advice works, but was hoping also
> for a easy way just to have autoptimize exclude a javascript file.
>
> I have tried this with the wp google analytics plugin and also just
> hardcoding the google script into the footer, but the outcome is the
> same.
>
> Any advice would be great,
> Thanks.
>
> Ben.
>
> --
> Autoptimize breaks Google Analytics
> https://bugs.launchpad.net/bugs/578713
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Autoptimize: Invalid
>
> Bug description:
> I tried your Autoptimize plugin for wordpress. blog.iobit.com
>
> Once I installed your plugin, it really worked, increased speed for opening
> my pages.
>
> However, since then, there is no Google Analytics data any more!
>
> two hours later, I found this issue, so I deleted your plugin at
> background.
>
> 2 hours later again, there is still no analytics data. I entered my server,
> found that there are some files of Autoptimize still there under cache
> folder. Then I deleted this folder completely.
>
> 1 hour later again, there is till no analytics data. I don't know where I
> didn't delete.
>
> During these period, I didn't edit any code of my blog, just installed and
> uninstalled your plugin.
>
> Is there anyway you can make my blog google analytics normal?
>
> I have already deleted Autoptimize files at background and cache folder at
> wp-content/
>
> Many thanks
>
> --
> Leonard Lambo
> GM Department
>
> IObit.com
> Http://blog.iobit.com
>
> Tel:+86-13402886117
> Email:<email address hidden> <Email%<email address hidden>>
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/autoptimize/+bug/578713/+subscribe
>

--
Leonard Lambo
GM Department

IObit.com
Http://blog.iobit.com

Tel:+86-13402886117
Email:<email address hidden> <Email%<email address hidden>>

Revision history for this message
Emilio (turl) wrote :

For a quick way to disable moving analytics scripts, check classes/autoptimizeScripts.php.

On $dontmove, add 'pieces' for each script tag that needs to stay in place. On $domove, remove the current analytics piece(s) (it's just jaJsHost if I recall correctly)

By the way, could you provide me with an example analytics code (you can change user IDs and that if you wish)? Just in case it changed and I need to add new rules for it on the plugin code :)

Looking forward to hearing from you,

Emilio

Revision history for this message
Ben Palmer (ben-graphnetwork) wrote :

Hi Emilio,

The good news is that your advice for checking the try - catch worked.

Since turning it on the reporting has returned.
Hopefully this is good news for the other people with the same problem here.

Thanks for your swift reply and great work,

Ben.

btw. Google tracking code looks like:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script>

Revision history for this message
Rance Lucifinil (lambo) wrote :

Please check the following new Google analytics codes which will be put in
<head></head>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1447202-8']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type =
'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
  })();

</script>

Yes, you can change your ID as your wish.

I will try later once you finished this update.

2010/6/15 Emilio <email address hidden>

> For a quick way to disable moving analytics scripts, check
> classes/autoptimizeScripts.php.
>
> On $dontmove, add 'pieces' for each script tag that needs to stay in
> place. On $domove, remove the current analytics piece(s) (it's just
> jaJsHost if I recall correctly)
>
> By the way, could you provide me with an example analytics code (you can
> change user IDs and that if you wish)? Just in case it changed and I
> need to add new rules for it on the plugin code :)
>
> Looking forward to hearing from you,
>
> Emilio
>
> --
> Autoptimize breaks Google Analytics
> https://bugs.launchpad.net/bugs/578713
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Autoptimize: Invalid
>
> Bug description:
> I tried your Autoptimize plugin for wordpress. blog.iobit.com
>
> Once I installed your plugin, it really worked, increased speed for opening
> my pages.
>
> However, since then, there is no Google Analytics data any more!
>
> two hours later, I found this issue, so I deleted your plugin at
> background.
>
> 2 hours later again, there is still no analytics data. I entered my server,
> found that there are some files of Autoptimize still there under cache
> folder. Then I deleted this folder completely.
>
> 1 hour later again, there is till no analytics data. I don't know where I
> didn't delete.
>
> During these period, I didn't edit any code of my blog, just installed and
> uninstalled your plugin.
>
> Is there anyway you can make my blog google analytics normal?
>
> I have already deleted Autoptimize files at background and cache folder at
> wp-content/
>
> Many thanks
>
> --
> Leonard Lambo
> GM Department
>
> IObit.com
> Http://blog.iobit.com
>
> Tel:+86-13402886117
> Email:<email address hidden> <Email%<email address hidden>>
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/autoptimize/+bug/578713/+subscribe
>

--
Leonard Lambo
GM Department

IObit.com
Http://blog.iobit.com

Tel:+86-13402886117
Email:<email address hidden> <Email%<email address hidden>>

Revision history for this message
Emilio (turl) wrote :

Sorry for not posting this earlier, but I have commited a fix I hope will resolve the issues with the new analytics code that goes on the site's head. It will come out with the next autoptimize version, but you can test it now and tell me if it works by downloading this file:

http://plugins.svn.wordpress.org/autoptimize/trunk/classes/autoptimizeScripts.php

And replace the current one on your autoptimize's installation (/wp-content/plugins/autoptimize/classes/autoptimizeScripts.php) with the one you downloaded. Then clean Autoptimize's cache (and WP-Super-Cache's if you use it) and check whether analytics breaks or not.

Looking forward to hearing from you!

Changed in autoptimize:
status: Invalid → Fix Committed
Revision history for this message
Andy Beard (list-andy) wrote :

I will try to do some testing on the new code.

Just in case you weren't aware of it, some implementation of the new GA code the async is placed after the opening <body> tag

Revision history for this message
Emilio (turl) wrote :

It doesn't really matter much when it comes to Autoptimize, but according to Google, the asynchronous code should be put just before </head>. From http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html :

"Insert the asynchronous snippet at the bottom of the <head> section of your pages, after any other scripts your page or template might use. [...] We've determined that on most pages, the optimal location for the asynchronous snippet is at the bottom of the <head> section, just before the closing </head> tag."

Please report back the results of your testing :)

Revision history for this message
Rance Lucifinil (lambo) wrote :

After two and half hours test, I enabled Optimize JavaScript Code? and
Optimize CSS Code? in the option,

And google analytics is still working. Congratulations.

2010/7/5 Emilio <email address hidden>

> It doesn't really matter much when it comes to Autoptimize, but
> according to Google, the asynchronous code should be put just before
> </head>. From
> http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html :
>
> "Insert the asynchronous snippet at the bottom of the <head> section
> of your pages, after any other scripts your page or template might use.
> [...] We've determined that on most pages, the optimal location for the
> asynchronous snippet is at the bottom of the <head> section, just before
> the closing </head> tag."
>
> Please report back the results of your testing :)
>
> --
> Autoptimize breaks Google Analytics
> https://bugs.launchpad.net/bugs/578713
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Autoptimize: Fix Committed
>
> Bug description:
> I tried your Autoptimize plugin for wordpress. blog.iobit.com
>
> Once I installed your plugin, it really worked, increased speed for opening
> my pages.
>
> However, since then, there is no Google Analytics data any more!
>
> two hours later, I found this issue, so I deleted your plugin at
> background.
>
> 2 hours later again, there is still no analytics data. I entered my server,
> found that there are some files of Autoptimize still there under cache
> folder. Then I deleted this folder completely.
>
> 1 hour later again, there is till no analytics data. I don't know where I
> didn't delete.
>
> During these period, I didn't edit any code of my blog, just installed and
> uninstalled your plugin.
>
> Is there anyway you can make my blog google analytics normal?
>
> I have already deleted Autoptimize files at background and cache folder at
> wp-content/
>
> Many thanks
>
> --
> Leonard Lambo
> GM Department
>
> IObit.com
> Http://blog.iobit.com
>
> Tel:+86-13402886117
> Email:<email address hidden> <Email%<email address hidden>>
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/autoptimize/+bug/578713/+subscribe
>

--
Leonard Lambo
GM Department

IObit.com
Http://blog.iobit.com

Tel:+86-13402886117
Email:<email address hidden> <Email%<email address hidden>>

Revision history for this message
Emilio (turl) wrote :

Nice to hear!

The fix will come out officially with the next version - maybe tomorrow, if time allows.

Emilio (turl)
Changed in autoptimize:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.