Commit e3c18d0c authored by hass's avatar hass

Issue #2727007 by hass: Update javascript tracking snippet

parent 747f83bf
......@@ -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);
}
}
......
......@@ -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.
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment