Hello,

When I run my site in Google Pagespeed Insights (GPI), I get the following notification (image attached) saying basically that loading the GA script from outside my site, actually slows it down a bit.

Seemingly, it gives a slightly lower GPI grade, and I would want to have these extra GPI points.

After reading about it in a quick search, it seems as a quite known issue that has been solved for WordPress but I don't know of a contributed solution for Drupal.

Given I am not a JS programmer, and just study basic PHP, I humbly ask to know if there is a way, or if you might be considering adding a way, to download and load the GA code daily & locally on a Drupal site, as a Cron task?

Thank you,

CommentFileSizeAuthor
#6 Options.JPG43.24 KBBenia
GPI-suggestion.JPG33.2 KBBenia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Benia created an issue. See original summary.

Benia’s picture

Issue summary: View changes
Benia’s picture

Issue summary: View changes
hass’s picture

Category: Feature request » Support request
Status: Active » Fixed

Looks like you are not using this module. Why are you opening cases than?

Benia’s picture

Status: Fixed » Closed (works as designed)

Of course I use it, I just didn't find data on the option I needed to check in a Google search but gladly there is now a particular explanation for all newcomers about this in Stackexchange.

http://drupal.stackexchange.com/questions/212860/downloading-and-loading...

Benia’s picture

Title: Downloading and loading the GA script daily & locally with Drupal Cron? » GA script seem not to load locally
Priority: Normal » Minor
Status: Closed (works as designed) » Active
FileSize
43.24 KB

Hello Alex,

I went to admin/config/system/google-analytics#edit-advanced and there checked: "Locally cache tracking code file".

I then ran Cron, flushed all caches both in Drupal (drush cr) and in server: Google PageSpeed / Cloudflare, and yet no change was seen.

I thought I should wait a day or so, so the new script will be downloaded but sadly after 2 days no change is seen --- When I run a GPI test, I still see the same issue regarding the GA script.

* I am just learning some basic PHP so can't debug in an IDE.
* No errors in drush ws --full.

Would appricate your help.

hass’s picture

Version: 8.x-2.0 » 8.x-2.x-dev
Status: Active » Closed (cannot reproduce)

I see it is working

(window,document,"script","/drupal8/sites/default/files/google_analytics/analytics.js?ocxqav","ga")

and there is also a test for local caching that does not fail.

You need to find the root cause on your system. If it is a bug in the modules we can fix it.

Benia’s picture

I still have this problem even after moving from shared hosting to VPS so performance not seem to bias (if it can, I don't know).

I have no errors in status report nor in drush ws --full ... Can you give me a direction what should I check?

Thank you Alex,

Benia’s picture

Status: Closed (cannot reproduce) » Active

Might it be that I actually need to download the script to a file from here and put it somewhere?

(I theorized that when I check the option but there is no file locally to be cached, it will load it from the web and I won't have the effect).

hass’s picture

Status: Active » Closed (cannot reproduce)

No, you do not need to download anything. Disable local caching.

Benia’s picture

Do you mean to Page cache maximum age, under admin/config/development/performance? It is disabled for 2 years already...