Skip to content

Commit

Permalink
Issue #2903906 by hass, kreynen: Assuming /404.html is at the root of…
Browse files Browse the repository at this point in the history
… site is confusing
  • Loading branch information
hass authored and Jen Lampton committed Jan 13, 2021
1 parent 6f2d510 commit 3ae6cec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions googleanalytics.module
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ function googleanalytics_preprocess_layout() {
// Track access denied (403) and file not found (404) pages.
if ($status == '403 Forbidden') {
// See http://www.google.com/support/analytics/bin/answer.py?answer=86927
$url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
$url_custom = '"' . $base_path . '403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
elseif ($status == '404 Not Found') {
$url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
$url_custom = '"' . $base_path . '404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}

// #2693595: User has entered an invalid login and clicked on forgot
Expand Down
6 changes: 4 additions & 2 deletions tests/googleanalytics.test
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ class GoogleAnalyticsBasicTest extends BackdropWebTestCase {
// Enable tracking code for all user roles.
config_set('googleanalytics.settings', 'roles', array());

$base_path = base_path();

// Test whether 403 forbidden tracking code is shown if user has no access.
$this->backdropGet('admin');
$this->assertRaw('/403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
$this->assertRaw($base_path . '403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');

// Test whether 404 not found tracking code is shown on non-existent pages.
$this->backdropGet($this->randomName(64));
$this->assertRaw('/404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
$this->assertRaw($base_path . '404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');

// DNT Tests:
// Enable system internal page cache for anonymous users.
Expand Down

0 comments on commit 3ae6cec

Please sign in to comment.