某种程度上我的_gaq.push
功能无效。如果我设置debug = true
我可以看到日志,我知道它会转到其他地方(当我有debug=false
时),因为我尝试添加日志。这是我的代码
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
var debug = false;
function send_data(text, url) {
if (debug) {
console.log("_gaq.push(['_trackEvent', 'Site-change', " + text + ", " + url + "]);");
} else {
_gaq.push(['_trackEvent', 'Site-change', text, url]);
}
}
$('.navigation .child a').unbind('click').on('click', function(e) {
var url = $(this).attr('href');
var text = $(this).text();
send_data(text, url);
});
有什么想法吗?