vue项目当作npm包
Vue Hotjar (Vue Hotjar)
This is a simple Vue plugin that will allow you to easily add Hotjar to any Vue project.
这是一个简单的Vue插件,可让您轻松地将Hotjar添加到任何Vue项目。
我为什么要使用它 (Why should I use it)
If you just add the Hotjar snippet to your site it will start tracking user activity regardless of the environment Eg. in development mode. This is undesirable and this extension will take care of that. It will also help you to easily manage your Hotjar ID's in staging and development environments.
如果仅将Hotjar代码段添加到您的网站,则无论环境如何,它都将开始跟踪用户活动。 在开发模式下。 这是不可取的,此扩展将解决此问题。 它还将帮助您在登台和开发环境中轻松管理Hotjar ID。
安装 (Install)
npm install vue-hotjar
Start using it in your Vue application.
在您的Vue应用程序中开始使用它。
import Vue from 'vue'
import Hotjar from 'vue-hotjar'
Vue.use(Hotjar, {
id: 'XXXXXXX' // Hotjar Site ID
})
参量 (Parameters)
ID: (Id:)
Your Hotjar Site ID is a required parameter and can be found on your Hotjar account.
您的Hotjar网站ID是必填参数,可以在您的Hotjar帐户中找到。
id: 'XXXXXXX'
snippetVersion: (snippetVersion:)
This optional parameter does not need to be specified as it will default to the latest Hotjar Snippet version. Currently, it will default to version 6
.
不需要指定此可选参数,因为它将默认为最新的Hotjar Snippet版本。 当前,它将默认为version 6
。
snippetVersion: 6
isProduction: (isProduction:)
If you would like to disable or enable tracking pass in either true
or false
. It is advised to bind your Node ENV. This is an optional parameter and will default to true if not specified.
如果您想禁用或启用跟踪,请输入true
或false
。 建议绑定您的节点ENV。 这是一个可选参数,如果未指定,则默认为true。
isProduction: true
完整的例子 (Full Example)
import Vue from 'vue'
import Hotjar from 'vue-hotjar'
Vue.use(Hotjar, {
id: 'XXXXXXX',
snippetVersion: 6,
isProduction: true
})
变更安装 (Varify Installation)
In order to verify your installation in a production environment or whenever the isProduction
parameter is set to true
, you can simply navigate to the below URL. If the installation is successful you should see a notification appear on your website indicating that Hotjar is receiving data and your implementation is successful.
为了在生产环境中或在isProduction
参数设置为true
时验证安装,您可以简单地导航至以下URL。 如果安装成功,您应该在网站上看到一条通知,指示Hotjar正在接收数据,并且您的实施成功。
https://[BASE-URL]/?hjVerifyInstall=[TRACKING-ID]
https://[BASE-URL]/?hjVerifyInstall=[TRACKING-ID]
Additionally you can verify the install by logging in to insights.hotjar.com and viewing the tracking status.
另外,您可以通过登录Insights.hotjar.com并查看跟踪状态来验证安装。
支持的Vue版本 (Supported Vue Versions)
-
Vue ^3.0.0
Vue ^ 3.0.0
-
Vue ^4.0.0
Vue ^ 4.0.0
翻译自: https://vuejsexamples.com/a-npm-package-to-easily-add-hotjar-to-any-vue-project/
vue项目当作npm包