通过jQuery插件进行Google Analytics事件跟踪 [英] Google Analytics Event Tracking via a jQuery plugin
问题描述
< script type =text / javascript>
$(document).ready(function(){
$('。evnttrk1')。click(function(){
_gaq.push(['_ trackEvent','coming_soon', 'footer_icons',$(this).attr('id')]);
});
});
一类eventrk1会触发Google Analytics事件。这工作得很好。
从那里开始,我决定将其推广到一个合适的插件中,并在此过程中增加一些功能。除了外,关于该插件的所有内容都适用 我无法让_gaq.push将事件发送给Google。我没有收到错误。我什么都没有得到。
我在即将推出的页面上运行插件: http:// AcaciaNJ 我想告诉你,这给了我灰色头发,但这是不可能的,因为它让我把我所有的头发都拉出来。请帮忙。这真的开始打扰我了。谢谢。 也许试试 您可以通过测试 您也可以将任意函数传递给 我还注意到您的脚本将第五个参数传递给 The proof of concept started with this: With this, any link with a class of eventrk1 would trigger a Google Analytics Event. This worked just fine. From there I decide to roll it into a proper plugin, adding some functionality along the way. Everything about the plugin works except I can't get the _gaq.push to send events to Google. I'm not getting an error. I'm not getting anything at all. I have the plugin running on this coming soon page: http://AcaciaNJ.com I'd like to tell you this gave me gray hairs but that's not possible since it made me pull all my hair out. Please help. This is really starting to bother me. Thanks. Maybe try You can detect if the You could also pass an arbitrary function to I also noticed that your script passes a fifth argument to 这篇关于通过jQuery插件进行Google Analytics事件跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
window._gaq.push
?
window._gaq $ c $来检测
_gaq
对象是否可用c>:
if(window._gaq){
alert('_ gaq found');
} else {
alert('_ gaq not found');
}
窗口。 _gaq.push()
来帮助调试:
window._gaq.push(function() {alert('推到_gaq的函数)});
_trackEvent
, val
。这必须是一个整数,如果它是一个字符串,跟踪将不起作用。<script type="text/javascript">
$(document).ready(function() {
$('.evnttrk1').click(function() {
_gaq.push(['_trackEvent', 'coming_soon', 'footer_icons', $(this).attr('id')]);
});
});
window._gaq.push
?_gaq
object is available by testing for window._gaq
:if (window._gaq) {
alert('_gaq found');
} else {
alert('_gaq not found');
}
window._gaq.push()
to help with debugging:window._gaq.push(function() {alert('Pushed function to _gaq')});
_trackEvent
, val
. This has to be an integer, and tracking will not work if it is a string.