Scripts

Clarity by Microsoft is a screen recorder and heatmap tool that helps you understand how users interact with your website.

https://store-images.s-microsoft.com/image/apps.29332.512b1d3d-80ec-4aec-83bb-411008d2f7cd.76371b6f-9386-463f-bfb0-b75cffb86a4f.bd99f4b1-b18e-4380-aa79-93768763c90d.png
Clarity

View source

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 is auto-enabled, routing all traffic through your domain for improved privacy and ad blocker bypass.

export default defineNuxtConfig({
  scripts: {
    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.