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.
- Download the Plugin
- You can get the MS Clarity Exclude Logged In Users plugin here.
- 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.
- Activate the Plugin
- Once installed, click Activate Plugin to start excluding logged-in users from Clarity tracking.
- 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.
- Open
functions.phpIn your WordPress Dashboard, go to Appearance > Theme Editor.- Open your active theme’s
functions.phpfile.
- 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' );
- Replace xxxxxxxxxx with Your Clarity ID
- Find your Microsoft Clarity ID in your Clarity account and replace xxxxxxxxxx in the script.
- 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.