WordPress Help Articles

MS Clarity Exclude Logged In Users

MS Clarity Exclude Logged In Users

Updated: January 21, 2025

Not associated with Microsoft® Clarity®

Improve Analytics Accuracy on WordPress

If you’re using Microsoft Clarity to track user behavior on your WordPress site, you might have noticed that logged-in users—like administrators, editors, and authors—can skew your analytics. Tracking these users results in inaccurate heatmaps, session replays, and insights that don’t reflect real visitor interactions.

To resolve this issue, Via Webs has developed a simple yet powerful WordPress plugin: MS Clarity Exclude Logged In Users. This plugin ensures that logged-in users with post-editing capabilities are excluded from Clarity tracking, helping you gather clean, accurate analytics data from actual visitors.
Why Exclude Logged-In Users from Microsoft Clarity?

By default, Microsoft Clarity tracks all users who visit your website, including administrators, editors, authors, and other logged-in users. This causes several issues:

  • Skewed Heatmaps & Click Data: Admins and editors often interact with the backend, making Clarity data less useful.
  • Irrelevant Session Recordings: Watching admin sessions in Clarity can be distracting and unnecessary.
  • Misleading Analytics Reports: If you rely on Clarity insights for UX improvements, including logged-in users can distort the real user experience.

The MS Clarity Exclude Logged In Users plugin automatically prevents Clarity from tracking logged-in users, ensuring only real visitors contribute to your data.

How to Use the MS Clarity Exclude Logged In Users Plugin

This plugin is easy to set up and requires no coding knowledge. Follow these steps to install and activate it on your WordPress site.

  1. Download the Plugin
    • You can get the MS Clarity Exclude Logged In Users plugin here.
  2. Install the Plugin on WordPress
    • Go to your WordPress Dashboard.
    • Navigate to Plugins > Add New.
    • Click the Upload Plugin button.
    • Choose the plugin ZIP file you downloaded and click Install Now.
  3. Activate the Plugin
    • Once installed, click Activate Plugin to start excluding logged-in users from Clarity tracking.
  4. Configure the Plugin with Your Clarity ID to complete the setup:
    • In the Plugins section, select plugin file editor
    • Find MS Clarity Exclude Logged In Users from the drop-down and click Edit.
    • Locate the line that contains xxxxxxxxxx (your Clarity ID placeholder).
    • Replace xxxxxxxxxx with your Microsoft Clarity tracking ID (found in your Clarity dashboard).
    • Save the changes.

Now, logged-in users with editing permissions (admins, editors, authors) will be excluded from Clarity tracking, while regular visitors remain trackable.

Alternative Method: Adding Custom Code Manually

If you prefer not to use a plugin, you can manually add the exclusion code to your WordPress functions.php file.

  1. Open functions.php
    • In your WordPress Dashboard, go to Appearance > Theme Editor.
    • Open your active theme’s functions.php file.
  2. Insert the Exclusion Code
    • function viawebs_plugins_clarity_exclude_logged_in(){
          if ( ! current_user_can( 'edit_posts' ) ) {
              ?>
          
      <script type="text/javascript">
          (function(c,l,a,r,i,t,y){
              c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
              t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
              y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
          })(window, document, "clarity", "script", "xxxxxxxxxx"); // <--- add the site id here
      </script>
      
          <?php
          }
      }
      add_action( 'wp_head', 'viawebs_plugins_clarity_exclude_logged_in' );
      
  3. Replace xxxxxxxxxx with Your Clarity ID
    • Find your Microsoft Clarity ID in your Clarity account and replace xxxxxxxxxx in the script.
  4. Save & Test
    • Save the functions.php file and visit your website while logged in as an admin or editor—the Clarity script should no longer load.

Benefits of Using the MS Clarity Exclude Logged In Users Plugin

  • Improved Analytics Accuracy – Ensure your Clarity insights reflect real user behavior.
  • Cleaner Heatmaps & Session Recordings – Focus only on actual visitors, not logged-in users.
  • Automatic Exclusion – No manual settings; works instantly after activation.
  • No Coding Required – Simple installation and easy setup.
  • Lightweight & Fast – Won’t slow down your WordPress site.

 

Via Webs Offers WordPress Hosting & Maintenance Services For Those That Prefer To Focus On Something Other Than The Technical Aspects

Our rollover development time lets you save unused hours for future assistance. Stay updated and optimized, with the flexibility to invest in new functionality.

Article Categories

Dive in to something specific you are wanting to learn more about.

  • Design: Explore our Design articles to master color theory, font pairing, and more, enhancing your website's visual appeal.
  • DIY: Empower yourself with our DIY guides, offering step-by-step instructions for hands-on WordPress customization.
  • E-Commerce: Unlock effective eCommerce strategies to boost your online store's visibility and drive sales.
  • Plugins: Discover essential WordPress plugins to enhance functionality, speed, and security for your website.
  • Security: Stay informed with our Security insights, ensuring your WordPress site remains protected against threats.
  • SEO: Learn top SEO techniques to improve your website's performance and visibility in search engine results.
  • Speed: Optimize your site's performance with our Speed tips, ensuring fast load times and a better user experience.
  • Support: Access our Support resources for affordable WordPress services, including hosting, maintenance, and migration.

Let's Get Started!