Nuxt Nation カンファレンス開催!11月12日〜13日参加登録受付中!

hotjar
nuxt-module-hotjar

HotjarをNuxtアプリケーションに追加

343866793-35f88f27-93d3-4fe1-9479-798414ea7353

Nuxt Hotjar

トラッキングと分析のために、Hotjar を簡単にNuxtアプリケーションに追加できます。

npm versionnpm downloadsLicenseNuxt

機能

  • 🔥 HotjarをNuxtアプリケーションに簡単に追加
  • 👮 データプライバシー
  • 🏷️ 完全型指定
  • 🦾 SSRサポート

設定

npx nuxi@latest module add hotjar

設定方法

nuxt.config.tsmodules セクションに nuxt-module-hotjar を追加し、HotjarサイトIDとスクリプトバージョンを指定します。

Nuxt Hotjarを実行するには、サイトID (モジュール内のhotjarId) で初期化する必要があります。サイトIDは、こちら のページで、サイト名の直前に表示されています。

export default defineNuxtConfig({
  modules: [
    'nuxt-module-hotjar'
  ],

  hotjar: {
    hotjarId: 1234567,
    scriptVersion: 6,

    // optionally you can turn on debug mode for development
    debug: true
  }
})

基本的な使用方法

コンポーザブル useHotjar を使用してHotjarをアプリで初期化する必要があります。

// In you app.vue file for example when you user has given consent:

const { initialize } = useHotjar()

function onConsent() {
  initialize()
}

コンポーザブル

useHotjar

SSR対応のuseHotjar コンポーザブルは、以下へのアクセスを提供します。

  • 初期化メソッド

このように使用できます。

const { initialize } = useHotjar()

型定義

function useHotjar(): {
  initialize: () => void
}

モジュールオプション

オプションデフォルト値説明
hotjarId数値undefinedHotjar の site_id
scriptVersion数値6デフォルトは6です。*変更する必要はありません。*
debugブール値falseデバッグモード

クレジット

開発

# 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