Vuejs使用Google Analytics进行事件跟踪 [英] Vuejs Event tracking using Google analytics
本文介绍了Vuejs使用Google Analytics进行事件跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< button id =openmodaldata-purpose =contact form class =btn__primaryaria-label =帮助@ click =contactForm>联系表单< / button>
在分析中
ga('send',{
hitType:'event',
eventCategory:'button',
eventAction:'data-purpose',
eventLabel: '价值的按钮'
});
解决方案
我最终使用 vue-analytics 。从作者
很容易遵循文档
I am looking to track google analytics events on buttons and links. In jquery typically, I would pass values in data-attributes and fetch them and call required function. I understand I shouldn't be using data-attributes so I am looking out for the best way of doing this , there can be multiple buttons that performs different tracking with different data-purpose (attribute) So I will need to pass data-purpose and data-user to the vue component/function
<button id="openmodal" data-purpose="contact form" class="btn__primary" aria-label="Help" @click="contactForm">Contact Form</button>
<button id="openmodal" data-purpose="Opt In" class="btn__primary" aria-label="Help" @click="optIn">Opt In</button>
In analytics
ga('send', {
hitType: 'event',
eventCategory: 'button',
eventAction: 'data-purpose',
eventLabel: 'VALUE OF BUTTON'
});
解决方案
I ended up using vue-analytics . There is Easy to follow documentation from the author
这篇关于Vuejs使用Google Analytics进行事件跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文