diff --git a/src/Actions.php b/src/Actions.php index 6e2ee22c..29918a77 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -84,7 +84,7 @@ public function maybe_register_assets() { // Track search results. Tracks a search event with the search term and the number of results, and a pageview with the site's search URL. if ( Helpers::is_enhanced_measurement_enabled( 'search' ) && is_search() ) { - global $wp_rewrite, $wp_query; + global $wp_query; $data = wp_json_encode( [ diff --git a/src/Helpers.php b/src/Helpers.php index fb8dd799..39c176a3 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -76,7 +76,7 @@ public static function get_filename( $local = false ) { } // Add the manual scripts as we need it to track the search parameter. - if ( self::is_enhanced_measurement_enabled( 'search' ) ) { + if ( is_search() && self::is_enhanced_measurement_enabled( 'search' ) ) { $file_name .= '.manual'; // @codeCoverageIgnore }