diff --git a/src/Tests/GoogleAnalyticsRolesTest.php b/src/Tests/GoogleAnalyticsRolesTest.php
index db69825..4f09312 100644
--- a/src/Tests/GoogleAnalyticsRolesTest.php
+++ b/src/Tests/GoogleAnalyticsRolesTest.php
@@ -22,7 +22,11 @@ class GoogleAnalyticsRolesTest extends WebTestBase {
    *
    * @var array
    */
-  public static $modules = ['google_analytics'];
+  public static $modules = [
+    'google_analytics',
+    'google_analytics_test',
+    'node',
+  ];
 
   /**
    * {@inheritdoc}
@@ -109,4 +113,19 @@ class GoogleAnalyticsRolesTest extends WebTestBase {
     $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is displayed on frontpage for included anonymous users.');
   }
 
+  /**
+   * Tests if the tracking visibility works for a specific route.
+   */
+  public function testGoogleAnalyticsVisibilityTracking() {
+    $this->drupalGet('admin/content');
+
+    $this->createContentType(['type' => 'page']);
+    $node = $this->drupalCreateNode(['type' => 'page']);
+
+    $this->drupalGet('node/' . $node->id(), ['query' => ['magic_ga_disable' => '']]);
+    $this->assertNoRaw('www.google-analytics.com/analytics.js');
+    $this->drupalGet('node/' . $node->id());
+    $this->assertRaw('www.google-analytics.com/analytics.js');
+  }
+
 }
diff --git a/tests/modules/google_analytics_test/google_analytics_test.info.yml b/tests/modules/google_analytics_test/google_analytics_test.info.yml
new file mode 100644
index 0000000..0b8ac30
--- /dev/null
+++ b/tests/modules/google_analytics_test/google_analytics_test.info.yml
@@ -0,0 +1,4 @@
+type: module
+name: Google Analytics Test
+description: 'Required for Google Analytics simpletests only.'
+core: 8.x
diff --git a/tests/modules/google_analytics_test/google_analytics_test.module b/tests/modules/google_analytics_test/google_analytics_test.module
new file mode 100644
index 0000000..9936b07
--- /dev/null
+++ b/tests/modules/google_analytics_test/google_analytics_test.module
@@ -0,0 +1,17 @@
+<?php
+/**
+ * @file
+ * Helper module for google_analytics test.
+ */
+
+/**
+ * Implements hook_google_analytics_visibility_pages().
+ *
+ * Depending on a specific active route, this function returns TRUE if JS code
+ * should be added to the current page, otherwise FALSE.
+ */
+function google_analytics_test_google_analytics_visibility_pages_alter(&$page_match) {
+  if ($page_match && \Drupal::request()->query->has('magic_ga_disable')) {
+    $page_match = FALSE;
+  }
+}
