vue项目当作npm包_NPM软件包可轻松将Hotjar添加到任何Vue项目

本文介绍了一个名为Vue Hotjar的简单Vue插件,该插件允许开发者轻松将Hotjar添加到Vue项目中,以实现用户行为跟踪。在开发模式下,Hotjar默认会跟踪所有活动,但通过此插件可以更好地管理和控制跟踪状态,同时提供参数配置,如Hotjar网站ID、snippet版本和生产环境设置。
摘要由CSDN通过智能技术生成

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.

如果您想禁用或启用跟踪,请输入truefalse 。 建议绑定您的节点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包

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值