GA Insert breaks 100% pagespeed :O

128 views
Skip to first unread message

david...@abiturma.de

unread,
Jun 5, 2015, 2:10:36 PM6/5/15
to mod-pagesp...@googlegroups.com
hi folks,

inserting GA via "EnableFilters insert_ga" unfortunately breaks our 100% pagespeed core (-2). The cache time is only 2 hours, which pagespeed insights does not like. For style reasons, we would like to change that, any chance? :)

cheerio

Jeff Kaufman

unread,
Jun 11, 2015, 11:46:58 AM6/11/15
to mod-pagespeed-discuss
Google Analytics depends on loading
http://www.google-analytics.com/ga.js and that has a 2hr cache
lifetime.

I don't know if this is compatible with the TOS for Analytics, but
from a technical perspective a way to fix this should be to use
MapProxyDomain:

ModPagespeedMapProxyDomain
http://yoursite.example.com/google-analytics/
http://www.google-analytics.com/

https://developers.google.com/speed/pagespeed/module/domains#MapProxyDomain

I haven't tested this, but once it's on your site cache extension
should work and you should get back to 100%.
> --
> You received this message because you are subscribed to the Google Groups
> "mod-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mod-pagespeed-di...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mod-pagespeed-discuss/829e5948-f13d-4bb1-8175-9179130b733b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Message has been deleted

david...@abiturma.de

unread,
Jun 14, 2015, 4:27:53 PM6/14/15
to mod-pagesp...@googlegroups.com
Hi Jeff,

thanks a lot for the help!

So basically what I tried was (on NGX):


But it doesnt seem to work. Is it possible that I somehow need to specifically allow Pagespeed to fetch resources from those servers?

Thanks again! :)

Jeff Kaufman

unread,
Jun 15, 2015, 10:00:53 AM6/15/15
to mod-pagespeed-discuss
What snippet are you using to load the js? You'll need to use a
declarative HTML one if you want PageSpeed to see it and rename it.
> --
> You received this message because you are subscribed to the Google Groups
> "mod-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mod-pagespeed-di...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mod-pagespeed-discuss/96cd8def-1046-488c-9968-e0426fb2ba42%40googlegroups.com.

david...@abiturma.de

unread,
Jun 20, 2015, 12:30:55 PM6/20/15
to mod-pagesp...@googlegroups.com
Hm, GA is being loaded via pagespeed itself. Well.. now when I think of it, that might be the problem, right? (Dunno the intrinsic order of Pagespeed - but is it possible that GA is inserted after MapProxyDomain has taken effect?)

Cheerio & thanks again!

attestation apostille

unread,
Jun 22, 2015, 4:33:03 AM6/22/15
to mod-pagesp...@googlegroups.com
hi 
  i Face a problem like 

The following requests are returning 404/410 responses. Either fix the broken links, or remove the references to the non-existent resources.


How can i fix this link or remove this link...

Jeff Kaufman

unread,
Jun 22, 2015, 3:47:19 PM6/22/15
to mod-pagespeed-discuss
I see, that's a PageSpeed bug. We insert a non-declarative version:

ga=document.createElement('script');
ga.type='text/javascript';
ga.async=true;
ga.src='http://www.google-analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga,s);

Since we're inserting the JS we should be able to make this work, but
it's something that won't work without us making code changes. I've
filed a bug: https://github.com/pagespeed/mod_pagespeed/issues/1099
>> > email to mod-pagespeed-di...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups
> "mod-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mod-pagespeed-di...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mod-pagespeed-discuss/8f904730-7e52-4bd4-9208-47c82dd30f92%40googlegroups.com.

david...@abiturma.de

unread,
Jul 22, 2015, 10:26:29 AM7/22/15
to mod-pagespeed-discuss
Sounds great, thanks! :)
Reply all
Reply to author
Forward
0 new messages