Scripts
Hotjar
Hotjar is a screen recorder and heatmap tool that helps you understand how users interact with your website.
Hotjar
Nuxt Config Setup
The simplest way to load Hotjar globally in your Nuxt App is to use Nuxt config. Alternatively you can directly use the useScriptHotjar composable.
export default defineNuxtConfig({
scripts: {
registry: {
hotjar: {
id: '1234567'
}
}
}
})useScriptHotjar()
The useScriptHotjar composable lets you have fine-grain control over when and how Hotjar is loaded on your site.
const { proxy } = useScriptHotjar()
proxy.hj('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: {
hotjar: {
id: '1234567'
}
}
}
})Example
Using Hotjar only in production while using the proxy to send events.
<script setup lang="ts">
const { proxy } = useScriptHotjar()
// noop in development, ssr
// just works in production, client
function handleAction() {
proxy.hj('event', 'conversion')
}
</script>
<template>
<div>
<button @click="handleAction">
Send Event
</button>
</div>
</template>idnumber required Your Hotjar Site ID.
svnumber = 6The Hotjar snippet version.