summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2017-09-24 21:39:36 (GMT)
committerhass2017-09-24 21:39:36 (GMT)
commitad1ab35d3aecdf203cb1c9e554443a8c1382643e (patch)
tree8f7b5e74e4dbd3aa8ddbdc4a2702cec1f0106dab
parentde446694ab0b874a97e53ce0ab685accc8671b8d (diff)
Issue #2727007 by hass: Update javascript tracking snippet7.x-2.4
-rw-r--r--googleanalytics.module7
-rw-r--r--googleanalytics.test20
2 files changed, 13 insertions, 14 deletions
diff --git a/googleanalytics.module b/googleanalytics.module
index eea9830..275262b 100644
--- a/googleanalytics.module
+++ b/googleanalytics.module
@@ -268,11 +268,10 @@ function googleanalytics_page_alter(&$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 (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_cache_url)) {
+ if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_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
@@ -474,7 +473,7 @@ function googleanalytics_user_presave(&$edit, $account, $category) {
function googleanalytics_cron() {
// Regenerate the tracking code file every day.
if (REQUEST_TIME - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {
- _googleanalytics_cache('http://www.google-analytics.com/analytics.js', TRUE);
+ _googleanalytics_cache('https://www.google-analytics.com/analytics.js', TRUE);
variable_set('googleanalytics_last_cache', REQUEST_TIME);
}
}
diff --git a/googleanalytics.test b/googleanalytics.test
index 89fe1e4..f88525c 100644
--- a/googleanalytics.test
+++ b/googleanalytics.test
@@ -83,7 +83,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// 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';
variable_set('googleanalytics_account', $ua_code);
@@ -104,7 +104,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin page.');
$this->drupalGet('admin/config/system/googleanalytics');
// Checking for tracking code 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.
variable_set('googleanalytics_visibility_pages', 1);
@@ -112,7 +112,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin page.');
$this->drupalGet('admin/config/system/googleanalytics');
// Checking for tracking code 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.');
@@ -170,7 +170,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
(function(q,u,i,c,k){window['GoogleAnalyticsObject']=q;
window[q]=window[q]||function(){(window[q].q=window[q].q||[]).push(arguments)},
window[q].l=1*new Date();c=i.createElement(u),k=i.getElementsByTagName(u)[0];
- c.async=true;c.src='//www.google-analytics.com/analytics.js';
+ c.async=true;c.src='https://www.google-analytics.com/analytics.js';
k.parentNode.insertBefore(c,k)})('ga','script',document);
ga('create', 'UA-123456-7');
ga('send', 'pageview');
@@ -181,7 +181,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Test whether tracking code uses latest JS.
variable_set('googleanalytics_cache', 0);
$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.
variable_set('googleanalytics_tracker_anonymizeip', 0);
@@ -265,7 +265,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Test whether debugging script has been enabled.
variable_set('googleanalytics_debug', 1);
$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.
@@ -275,7 +275,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Test whether debugging script has been disabled.
variable_set('googleanalytics_debug', 0);
$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 tracker.
$codesnippet_create = array(
@@ -782,13 +782,13 @@ class GoogleAnalyticsPhpFilterTest extends DrupalWebTestCase {
// Check tracking code visibility.
variable_set('googleanalytics_pages', '<?php return TRUE; ?>');
$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.');
variable_set('googleanalytics_pages', '<?php return FALSE; ?>');
$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.
variable_set('googleanalytics_pages', '<?php return TRUE; ?>');