Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Add Microsoft Clarity to WordPress without a plugin

Add the Microsoft Clarity tracking code with one Snipfire snippet and your project ID. Here is what you give up compared with Microsoft's own plugin.

What Microsoft Clarity does

Microsoft's Clarity plugin connects your site to a Clarity project from the WordPress admin and adds the Clarity tracking code. The plugin on WordPress.org

What the snippet does the same

  • The same Clarity script loads in the page head, so session recordings, heatmaps and insights work in Clarity as usual.
  • Your data lives in your Clarity account either way.

What's different

  • The plugin creates or connects a project for you from the admin. With the snippet, you copy your project ID from Clarity > Settings > Setup and paste it in.
  • The snippet doesn't record visits by administrators, through a Snipfire condition you can change. The plugin adds the script for every visitor.
  • The plugin also reports page requests to Clarity from the server and offers Clarity's Brand Agents shopping assistant. The snippet only adds the tracking script.

When to keep the plugin Keep the plugin if you want to set Clarity up from the WordPress admin or use Brand Agents.

The snippet: Microsoft Clarity

Adds Microsoft Clarity (heatmaps and session recordings). Visits by administrators aren’t recorded.

HTML
<!-- Replace YOUR_PROJECT_ID with your Clarity project ID. -->
<script>
(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", "YOUR_PROJECT_ID");
</script>

Notes, where it runs and what it was tested with

Switching from the plugin

  1. Install the snippet in Snipfire (it arrives switched off).
  2. Deactivate Microsoft Clarity.
  3. Switch the snippet on. Snipfire checks the code and test-loads your site first.
  4. Check the page it affects, then delete the plugin.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.