Nuxt Clarity Analytics
一个模块,可轻松将 Clarity Analytics 集成到您的 Nuxt 3 项目中。
!注意 我建议您尝试一下 Nuxt Scripts,这是一个更完整的解决方案。
功能
- ✅ 适用于使用 Nitro 的 Nuxt 3 (SSR 和 SSG)
快速设置
- 将
nuxt-clarity-analytics
依赖项添加到您的项目中
npx nuxi@latest module add clarity-analytics
- 将
nuxt-clarity-analytics
添加到nuxt.config.ts
的modules
部分
export default defineNuxtConfig({
modules: [
'nuxt-clarity-analytics'
]
})
然后,您必须在环境变量中注册您的 Clarity ID 项目 NUXT_CLARITY_ID
。
大功告成!
您可以通过在浏览器中检查页面来轻松验证脚本是否正确注入。请注意,如果缺少密钥,则不会注入任何内容!
您还可以使用 util clarityContent
在用户同意的情况下使用 cookie。它是 window.clarity
的一个包装器。查看 Clarity 文档。
开发
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release