1

I'm optimizing my website using GTmetrix and I've got good grades, but it's still not perfect.

Look at this image for PageSpeed:

pagespeed image

And this one for YSlow:

yslow image

The picture shows that my value is not perfect because I installed the Google Analytics script on my website. If I delete it, I can get a perfect score, but I need Google Analytics to analyze my website.

So how do I optimize the Google Analytics script on my website without removing it?

2

It's a real pain that Google reccomends this on their own products. I have looked into doing this before and I have found a couple of solutions but nothing is perfect and i've found that having a 100/100 score doesn't really provide a worthwhile improvement over something like 80/100.

There are a few good sites i've found while researching whether I should do this myself. Most sites I have looked at suggest one of the best options is to host the Google Analytics code locally.

https://www.keycdn.com/blog/leverage-browser-caching

https://technumero.com/leverage-browser-caching-google-analytics/

| improve this answer | |
  • thanks. I will try that link. yesterday I had thought to host the Google Analytics code locally. but I am afraid if there is a change from the Google Analytics script. it does not update in the local – happy forever Sep 28 '19 at 20:53
  • That will be an issue. Plus as far as I know there is no easy way to know when they've updated the code. – Michael Scott Sep 28 '19 at 21:30
  • yes. from your link says to use cron job. maybe it is a solution – happy forever Sep 28 '19 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.