ga或_gaq.push用于Google Analytics(分析)事件跟踪? [英] ga or _gaq.push for Google Analytics event tracking?

查看:382
本文介绍了ga或_gaq.push用于Google Analytics(分析)事件跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想跟踪一个网站页面上按钮的 onclick ,条件通过后检查是否存在cookie。

I would like to track an onclick of a button on a page on a site, after a condition is passed checking if a cookie is present.

很简单,但哪种语法最有效?

Very simple but which syntax would work best?

我研究过 ga gaq_push GA事件跟踪语法的前缀(原谅我,如果我错了),但他们看起来很相似?

I have researched the ga and gaq_push prefix of the GA event tracking syntax and (forgive me if I'm wrong) but they seem pretty similar?

_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

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>


推荐答案

如果您使用 ga.js (传统异步代码)您必须使用_gaq.push。如果您使用 analytics.js ,则需要使用ga发送。这些方法是不可互换的,它们属于Google Analytics(分析)跟踪代码的两个不同版本。

If you use ga.js ("traditional" asynchronous code) you have to use _gaq.push. If you use analytics.js you need to use ga send. The methods are not interchangeable, they belong to two different versions of the Google Analytics tracking code.

这篇关于ga或_gaq.push用于Google Analytics(分析)事件跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆