【发布时间】:2013-09-12 20:51:38
【问题描述】:
在通过条件检查是否存在 cookie 后,我想跟踪网站页面上按钮的 onclick。
非常简单,但哪种语法效果最好?
我研究了 GA 事件跟踪语法的 ga 和 gaq_push 前缀(如果我错了,请见谅)但它们看起来很相似?
_gaq.push
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('entry_winagrand_cookie') !== null) {
jQuery('notregisterbtn').on('click', function () {
_gaq.push(['_trackEvent', 'QR_Win_A_Grand', 'Clicked through to Register']);
});
}
});
</script>
ga
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('entry_winagrand_cookie') !== null) {
jQuery('notregisterbtn').on('click', function () {
ga('send', 'event', 'button', 'click', 'QR_Win_A_Grand', 'Clicked_through_to_register');
});
}
});
</script>
【问题讨论】:
标签: jquery events google-analytics tracking