在 jspx 文件中,我有用于跟踪登录提供商的 js 脚本(用户通过电子邮件、facebook 或 twitter 登录)。
var statsAnalytics = "${jndiSettings['statsAnalytics']}";
var _gaq = _gaq || [];
_gaq.push(['_setAccount', statsAnalytics]);
_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 providerId = '${providerId}';
if (providerId) {
_gaq.push(['_trackEvent', 'Sign in', providerId, 'Signed in with ' + providerId]);
}
使用 Chrome 的 GA 调试器进行调试后,我得到:
_gaq.push processing "_setAccount" for args: "[UA-xxxxxxx-x]": [VM] ga_debug.js (9935):24
_gaq.push processing "_trackPageview" for args: "[]": [VM] ga_debug.js (9935):24
Track Pageview [VM] ga_debug.js (9935):24
_gaq.push processing "_trackEvent" for args: "[Sign in,facebook,Signed in with facebook]": [VM] ga_debug.js (9935):24
Track Event
为什么我的脚本不发送跟踪信标?