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