summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2017-09-24 21:36:59 (GMT)
committerhass2017-09-24 21:36:59 (GMT)
commite3c18d0c941327fa2174e7c733c6664c658337eb (patch)
tree0d2eb770e53e65ca13839f269fc0da57e8653540
parent747f83bfd14d93e7724557bbf8f616622a7053e5 (diff)
Issue #2727007 by hass: Update javascript tracking snippet8.x-2.2
-rw-r--r--google_analytics.module7
-rw-r--r--src/Tests/GoogleAnalyticsBasicTest.php14
-rw-r--r--src/Tests/GoogleAnalyticsPhpFilterTest.php6
3 files changed, 13 insertions, 14 deletions
diff --git a/google_analytics.module b/google_analytics.module
index ae2acf5..addd4ec 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 a8f945d..04926f1 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');
</script>
@@ -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 1673ec0..df4af76 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', '<?php return TRUE; ?>')->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', '<?php return FALSE; ?>')->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', '<?php return TRUE; ?>')->save();