diff --git a/google_analytics.module b/google_analytics.module index ae2acf5d1e877f5994a64a29e58db8f5cfdab7b1..addd4ec27ec7fcb790af003c76f6a82efd88f958 100644 --- a/google_analytics.module +++ b/google_analytics.module @@ -245,11 +245,10 @@ function google_analytics_page_attachments(array &$page) { $script .= '})(window,document,"script",'; // Which version of the tracking library should be used? - $library_tracker_url = '//www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js'); - $library_cache_url = 'http:' . $library_tracker_url; + $library_tracker_url = 'https://www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js'); // Should a local cached copy of analytics.js be used? - if ($config->get('cache') && $url = _google_analytics_cache($library_cache_url)) { + if ($config->get('cache') && $url = _google_analytics_cache($library_tracker_url)) { // A dummy query-string is added to filenames, to gain control over // browser-caching. The string changes on every update or full cache // flush, forcing browsers to load a new copy of the files, as the @@ -447,7 +446,7 @@ function google_analytics_cron() { // Regenerate the tracking code file every day. if (REQUEST_TIME - \Drupal::state()->get('google_analytics.last_cache') >= 86400 && $config->get('cache')) { - _google_analytics_cache('http://www.google-analytics.com/analytics.js', TRUE); + _google_analytics_cache('https://www.google-analytics.com/analytics.js', TRUE); \Drupal::state()->set('google_analytics.last_cache', REQUEST_TIME); } } diff --git a/src/Tests/GoogleAnalyticsBasicTest.php b/src/Tests/GoogleAnalyticsBasicTest.php index a8f945da4eda41f203dde0254f3634629f46aaf8..04926f183d95573e8ffd5fb0afa27a98efe4d56c 100644 --- a/src/Tests/GoogleAnalyticsBasicTest.php +++ b/src/Tests/GoogleAnalyticsBasicTest.php @@ -119,7 +119,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { // Verify that no tracking code is embedded into the webpage; if there is // only the module installed, but UA code not configured. See #2246991. $this->drupalGet(''); - $this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.'); + $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.'); $ua_code = 'UA-123456-1'; $this->config('google_analytics.settings')->set('account', $ua_code)->save(); @@ -140,7 +140,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { $this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin page.'); $this->drupalGet('admin/config/system/google-analytics'); // Checking for tracking URI here, as $ua_code is displayed in the form. - $this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.'); + $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.'); // Test whether tracking code display is properly flipped. $this->config('google_analytics.settings')->set('visibility.request_path_mode', 1)->save(); @@ -148,7 +148,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { $this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin page.'); $this->drupalGet('admin/config/system/google-analytics'); // Checking for tracking URI here, as $ua_code is displayed in the form. - $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.'); + $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.'); $this->drupalGet(''); $this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is NOT displayed on front page.'); @@ -194,7 +194,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,"script","//www.google-analytics.com/analytics.js","ga"); + })(window,document,"script","https://www.google-analytics.com/analytics.js","ga"); ga('create', 'UA-123456-7'); ga('send', 'pageview'); @@ -204,7 +204,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { // Test whether tracking code uses latest JS. $this->config('google_analytics.settings')->set('cache', 0)->save(); $this->drupalGet(''); - $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.'); + $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.'); // Test whether anonymize visitors IP address feature has been enabled. $this->config('google_analytics.settings')->set('privacy.anonymizeip', 0)->save(); @@ -291,7 +291,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { // Test whether debugging script has been enabled. $this->config('google_analytics.settings')->set('debug', 1)->save(); $this->drupalGet(''); - $this->assertRaw('//www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.'); + $this->assertRaw('https://www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.'); // Check if text and link is shown on 'Status Reports' page. // Requires 'administer site configuration' permission. @@ -301,7 +301,7 @@ class GoogleAnalyticsBasicTest extends WebTestBase { // Test whether debugging script has been disabled. $this->config('google_analytics.settings')->set('debug', 0)->save(); $this->drupalGet(''); - $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.'); + $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.'); // Test whether the CREATE and BEFORE and AFTER code is added to the // tracking code. diff --git a/src/Tests/GoogleAnalyticsPhpFilterTest.php b/src/Tests/GoogleAnalyticsPhpFilterTest.php index 1673ec001cdddcb4e0d511e26ce792c2abd01cbc..df4af7617e80f18b2c51f6b43243b3246ff16486 100644 --- a/src/Tests/GoogleAnalyticsPhpFilterTest.php +++ b/src/Tests/GoogleAnalyticsPhpFilterTest.php @@ -63,13 +63,13 @@ class GoogleAnalyticsPhpFilterTest extends WebTestBase { // Check tracking code visibility. $this->config('google_analytics.settings')->set('visibility.request_path_pages', '')->save(); $this->drupalGet(''); - $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.'); + $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.'); $this->drupalGet('admin'); - $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.'); + $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.'); $this->config('google_analytics.settings')->set('visibility.request_path_pages', '')->save(); $this->drupalGet(''); - $this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.'); + $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.'); // Test administration form. $this->config('google_analytics.settings')->set('visibility.request_path_pages', '')->save();