Don't fire tags for logged in Wordpress users

I would like to set the Matomo Tag Manager to not fire tags when the user is logged into wordpress or in other words, if the user is making page calls with wpadminbar visible, tags should not fire.
grafik
How can I do that?

Does no one have an idea/solution?
I assumed that I am not the first with this problem. Unfortunately, my search has not revealed a solution yet.

You could try a similar apporach to this: How to track form submissions using tag manager?

  1. Check for the existence of the admin bar with a customJS
function checkWpAdminBar() {
  var isWpAdmin = document.querySelector('#wpadminbar');
  
  if (isWpAdmin && isWpAdmin.style.display === 'block') { # ← check if it is set to block or delete the second check if the div is not present for non logged in users
    return true;
  } else {
    return false;
  }
}
  1. Make other tags dependent on this variable. (Don't execute this tag when any of these triggers have been triggered.)