Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
vue-ba
Advanced tools
Readme
vuejs 百度统计埋点插件
https://github.com/minlingchao1/vue-ba
npm install vue-ba --save
直接在页面中引用
<script src="./node_modules/vue-uweb/dist/index.js"><script>
或者通过es6模块加载
import ba from 'vue-ba'
使用vue-ba插件
Vue.use(ba, 'YOUR_SITEID_HERE')
通过传递 options 参数进行更多设置
Vue.use(uweb,options)
参数 | 必须 | 默认 | 说明 | 备注 |
siteId | 是 | 绑定要接受API请求的统计代码 | ||
debug | 否 | false | 调试模式下将在控制台中输出调用window._hmt时传递的参数 | 请不要在生产环境中使用,避免造成安全隐患 |
src | 否 | https://hm.baidu.com/hm.js?SITEID | 指定统计脚本标签的 src 属性 |
用于发送页面上按钮等交互元素被触发时的事件统计请求。
this.$ba.trackEvent(category,action,opt_label,opt_value)
参数 | 必须 | 类型 | 说明 |
category | 是 | string | 表示事件发生在谁身上 |
action | 是 | string | 表示访客跟元素交互的行为动作 |
opt_label | 否 | string | 用于更详细的描述事件 |
opt_value | 否 | int | 用于填写打分型事件的分值,加载时间型事件的时长,如果填写为其他形式,系统将按0处理。若填写为浮点小数,系统会自动取整,去掉小数点。 |
用于发送某个URL的PV统计请求,适用于统计AJAX、异步加载页面,友情链接,下载链接的流量
this.$ba.trackPageview(pageURL)
参数 | 必须 | 类型 | 说明 |
pageURL | 是 | string | 自定义虚拟PV页面的URL地址,填写以斜杠‘/’开头的相对路径,系统会自动补全域名 |
vue-ba 提供 track-event,track-pageview 两个指令,开发者可以直接在 html 模版中使用来统计网站数据
使用指令 v-track-event 监听事件, 通过 modifiers 指定事件类型,将自动为绑定元素添加事件监听,当事件触发调用统计代码。 如不指定事件,默认监听 click 事件。
可通过逗号分隔的字符串或对象字面量传递参数,以字符串传递时请注意参数顺序,可参考trackEvent API。
<button v-track-event.click="'category, action''"></button> // 统计click事件
<button v-track-event="'category, action'"></button> // 统计click事件简写
<input v-track-event.keypress="'category, action'"> // 统计keypress事件
<button v-track-event="'category, action, opt_label, opt_value'"><button> // 以字符串传递参数
<button v-track-event="{category:'event', action:'click'}"></button> // 以对象字面量传递参数
使用指令 track-pageview 统计虚拟 PV ,一般可以配合 v-show 或 v-if 来统计局部动态视图的 PV。
可通过逗号分隔的字符串或对象字面量传递参数,以字符串传递时请注意参数顺序,可参考trackPageview API 用法
<div v-show="show" v-track-pageview="'/bar'">bar</div> // 跟踪 v-show 绑定元素的虚拟pv
<div v-if="show" v-track-pageview="'/foo'">foo</div> // 跟踪 v-if 绑定元素的虚拟pv
<div v-track-pageview="'/tar'"></div> // 以字符串指定受访页面和来源
<div v-track-pageview="{pageURL:'/zoo''}"></div> // 以对象字面量指定受访页面和来源
FAQs
baidu analystics vue module
The npm package vue-ba receives a total of 45 weekly downloads. As such, vue-ba popularity was classified as not popular.
We found that vue-ba demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.