AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
1.6K members online now
1.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Cache analytics.js for PageSpeed?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I don't understand why the original code of Google Analytics / Universal Analytics will be penalized by Google PageSpeed (!):

 

Google PageSpeed says:

 

Leverage browser caching for the following cacheable resources:

http://www.google-analytics.com/analytics.js (2 hours)

 

When I put a copy of analytics.js in my server/cache, Tag Assistant (by Google) will tell me:

 

"Missing analytics.js script"

 

Is there any official solution or workaround for this?
Thanks in advance,
Miguel

1 Expert replyverified_user

Re: Cache analytics.js for PageSpeed?

Rising Star
# 2
Rising Star
Hi Miguel,

People have come up with proxy solutions or rewriting it a bit, but we don't recommend any correction for this. I would not worry about it; the only benefit is the last notch on the pages peed tool. If you try to host locally you could but then you will miss out on updates to the analytics.js library (which do happen).

Best,

Theo Bennett

Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Cache analytics.js for PageSpeed?

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

What do you think about this workaround?

1. Download analytics.js
2. Update the file daily (php script + cron)
3. Cache .js in .htaccess (as usual)
4. Add the URL of the local updated copy of analytics.js in GA code

http://themefreak.net/blog/how-to-cache-google-analytics-code/


Re: Cache analytics.js for PageSpeed?

Rising Star
# 4
Rising Star

Hey Miguel,

I think that would work as long as your updating the code, I just don't think you are going to see any real world benefit from doing it. Smiley Happy You're probably going to trade one alert for another. That is, you'll probably throw errors in tag assistant etc. but like the caching prompt for analytics.js; it can be ignored.

Best,

Theo
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Cache analytics.js for PageSpeed?

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
In regards if any Components are ignored then the (RAM) Random Access Memory has no life and the overall will be Chopped and Secured like YouTube use to be follow the fine-print of Adobe Acrobat

RawBreedCeo

Cache analytics.js for PageSpeed?

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi,

I removed the code of google analytics in my header, I uninstall my google analytics plugin in wordpress, but pagespeed continue to tell me that google analytics get my website slower.

Why? What can I do?

 

many thanks

www.fisioterapiarubiera.com