Check the current page is a view
You could use the name of the current route:

$current_route_name = \Drupal::service('current_route_match')-&gt;getRouteName();


The route names from views are built like this view.[view_name].[display_id].

You can list the existing routes with Drupal Console:

drupal router:debug