The statistics module adds a js library to the node build. You can remove it if you don't want to count the node:
mymodule.module
/**
* Implements hook_ENTITY_TYPE_view_alter() for node entities.
*/
function mymodule_node_view_alter(array &$build) {
$roles = \Drupal::currentUser()->getRoles();
if (!in_array('special_role', $roles)) {
if (isset($build['#attached']['library'])) {
$key = array_search('statistics/drupal.statistics', $build['#attached']['library']);
if ($key !== FALSE) {
unset($build['#attached']['library'][$key]);
}
}
}
}
This only works if the roles are altering permissions. If not, add a cache context for the user roles:
$build['#cache']['contexts'][] = 'user.roles';