Problem/Motivation

Doesn't possible to use option "Locally cache tracking code file".

error: Refused to execute script from 'https://****/sites/default/files/googleanalytics/js?rrksba' because its MIME type ('') is not executable, and strict MIME type checking is enabled.

Steps to reproduce

Enable option "Locally cache tracking code file" and check JS errors

Proposed resolution

The cached file should have extension "js"

Remaining tasks

User interface changes

API changes

Data model changes

Comments

M@ster created an issue. See original summary.

Greg Varga’s picture

A temporary, quick fix until the official solution comes out.

all/modules/contrib/google_analytics/googleanalytics.module
index f7325a92..b4308522 100644
--- a/sites/all/modules/contrib/google_analytics/googleanalytics.module
+++ b/sites/all/modules/contrib/google_analytics/googleanalytics.module
@@ -540,8 +540,7 @@ function googleanalytics_search_get_keys() {
  */
 function _googleanalytics_cache($location, $synchronize = FALSE) {
   $path = 'public://googleanalytics';
-  $file_destination = $path . '/' . basename($location);
+  $file_destination = $path . '/' . basename($location, ".js").".js";

   if (!file_exists($file_destination) || $synchronize) {
     // Download the latest tracking code.
     $result = drupal_http_request($location);
cboyden’s picture

Status: Active » Needs review
StatusFileSize
new560 bytes

I've added the above suggested code as a patch so it can be tested.

anybody’s picture

Just ran into the same issue. Any idea why this happened exactly NOW?

Any Drupal core changes or browser updates that may have caused this?

briand44’s picture

The patch in #3 applied cleanly against 7.x-2.8 and resolved this issue for us, thanks!