Clarity
Clarity by Microsoft is a screen recorder and heatmap tool that helps you understand how users interact with your website.
When first-party mode is enabled, all traffic is routed through your server. Partial privacy controls are applied — some data is anonymized while preserving what the script needs for accurate reporting.
Nuxt Config Setup
The simplest way to load Clarity globally in your Nuxt App is to use Nuxt config. Alternatively you can directly use the useScriptClarity composable.
export default defineNuxtConfig({
scripts: {
registry: {
clarity: {
id: 'xxxxxxxxxx'
}
}
}
})useScriptClarity()
The useScriptClarity composable lets you have fine-grain control over when and how Clarity is loaded on your site.
const { proxy } = useScriptClarity()
proxy.clarity('event', 'conversion')Please follow the Registry Scripts guide to learn more about advanced usage.
First-Party Mode
This script supports First-Party Mode which routes all traffic through your domain for improved privacy and ad blocker bypass.
export default defineNuxtConfig({
scripts: {
firstParty: true,
registry: {
clarity: { id: 'xxxxxxxxxx'}
}
}
})Example
Using Clarity only in production while using the proxy to send events.
<script setup lang="ts">
const { proxy } = useScriptClarity()
// noop in development, ssr
// just works in production, client
function handleAction() {
proxy.clarity('event', 'conversion')
}
</script>
<template>
<div>
<button @click="handleAction">
Send Event
</button>
</div>
</template>idstring required The Clarity token.