• Resolved Tony Zeoli

    (@tonyzeoli)


    Hi,

    First, I want to say that I love this plugin and it has been so helpful to me and all my client sites.

    But, I am not realizing when I try to score 100 in Page Speed Insights, Google’s tracking code inserted by your plugin and others like All in One SEO (when you add the UA number) enable the Google javascript, but it will always come up as render blocking.

    I’ve learned how to deal with this by using the Complete Analytics Optimization Suite plugin to host the Google tracking code locally and run a cron job to update it automatically when GA updates the script for any reason.

    I would love to keep GADWP active, but you can’t run both plugins at the same time, because the optimizer needs to deal with the GA script locally and your plugin loads the GA script in the page.

    Have you thought about this? Are there plans to do anything about this. I’d love to keep using this plugin on all my sites, but will be forced to remove it if the plugin can’t add the tracking code locally and run a cron job to keep it updates.

    Please let me know what you see the solution being. Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • I would love to keep GADWP active, but you can’t run both plugins at the same time, because the optimizer needs to deal with the GA script locally and your plugin loads the GA script in the page.

    Actually you can, see the tracking documentation, you can disable the tracking component at any time.

    I’ve learned how to deal with this by using the Complete Analytics Optimization Suite plugin to host the Google tracking code locally and run a cron job to update it automatically when GA updates the script for any reason.

    Are you aware of Google’s recommendations? See https://support.google.com/analytics/answer/1032389?hl=en.

    Have you thought about this? Are there plans to do anything about this. I’d love to keep using this plugin on all my sites, but will be forced to remove it if the plugin can’t add the tracking code locally and run a cron job to keep it updates.

    No there are no plans.

    Keep in mind that there is a thin line between optimizing and over-optimizing, and I would never recommend crossing it. Beside that it will be a nightmare to maintain such a website, over-optimizing will always generate all sorts of second-effects which need to be addressed individually. But after all it’s your decision, just keep in mind that chasing perfection will always have its downsides.

    FYI: You’re talking about ga.js, I would like you to remind you that analytics.js is the latest JavaScript library, which must be used: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs

    Alin, while your points are certainly valid, I have to agree with Tony here. There is plenty of precedent for widely used scripts and libraries to be hosted locally – e.g. jQuery. And in the case of the 13K analytics.js file, it can make a difference to bring in it to the local cache of scripts, especially when minified and combined.

    I’m currently in the process of adding a new view which will target the local analytics.js file saved by CAOS, and I’ll use some kind of PHP trickery to make your plugin load this new view instead of the default one.

    I’ll post code here when I figure it out.

    Also, to your point that CAOS is loading ga.js instead of analytics.js, it is not:

    // Remote file to download
    $remoteFile = 'https://www.google-analytics.com/analytics.js';
    $localfile = dirname(dirname(__FILE__)) . '/cache/local-ga.js';
    ...
    ...
    

    And while we’re at it, another cool way to load the analytics code is from an alternate CDN, like this: https://cdnjs.com/libraries/ga-lite

    All this would really take it one new text field for an alternate script location. That would satisfy GA purists who want to use the google hosted version, pagespeed junkies who need to satisfy crazy clients (or themselves), and thhose who don’t want to maintain their own analytics code but are cool with a stripped down version with longer cache time (like me).

    Thanks for considering this feature!

    I can add a filter which will allow you to change the resource url. This way, no additional option is needed while advanced users can manipulate the loading location as they wish. What do you think?

    Hi @deconf, adding the filter would be perfect. I understand that chasing 100/100 is arbitrary, even dumb. However, there are people (mostly clients) that see this metric as direct reflection of one’s technical SEO ability. Actually that is the reason why I’m here — Some agency was poaching my client earlier this week with promise of better PageSpeed scores. After few hours of work i got to 98/100. To be honest, after all that tuning, I kinda want to push it to 100/100. I can work out my the cron part server side. Thanks for understanding!

    Hi,

    That filter is already available (gadwp_analytics_script_path). Here’s the full list of hooks: https://github.com/deconf/Google-Analytics-Dashboard-for-WP/.

    Oh, sorry that I opened this topic then. I ended up here searching support forums and since the thread was open ended, I continued discussion here. Some people might end up here searching Google, so I’ll sum it up. Please, correct me if I’m wrong, everything bellow is my speculation and might be pile of horse shit:

    GADWP will work with ga-lite.js, that exists just for the sole reason of getting 99/100 to 100/100 in Google PageSpeed Insights.

    Now assuming I’m right, as end user you need to add this code to your functions.php file:

    add_filter ( 'gadwp_analytics_script_path', '//cdnjs.cloudflare.com/ajax/libs/ga-lite/2.0.1/ga-lite.min.js');

    There is a difference between analytics.js and ga-lite.js outlined here. Obviously, another drawback of unofficial tracking script is you have to watch for updates here or in github repo manually (although it gets updated rarely)… or you can write some script to refresh it.

    Alternatively, if one wants to use official Google Analytics script, he needs to download the current version from https://www.google-analytics.com/analytics.js store in in CDN or locally and put appropriate update mechanism in place (cron for example).

    Somenthig like this:

    add_filter ( 'gadwp_analytics_script_path', 'a_function_name');
    
    function a_function_name (){
       return '//link/to/your/local/script/analytics.js';
    }
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘ga.js and Page Speed Insights’ is closed to new replies.