根据谷歌分析,我们的帐户正在接收数据。我周一上传到我们的Alpha 网站,到目前为止,我只能在 19 日看到 1 次访问,而在本周剩下的时间里什么也没有,我让其他办公室和其他州的人访问了该网站 :(
好奇您是否会发现下面的代码有明显错误:一切看起来都很好,即使是搜索词跟踪也有效(解决了这个词)
//GOOGLE ANALYTICS
//======================================================================
WHOAT.analytics = (function ($, w, undefined) {
'use strict';
//initial google setup
var _gaq = _gaq || [];
_gaq.lang = 'en';
_gaq.push(['_setAccount', 'UA-xxxxx-x']);
_gaq.push(['_setDomainName', 'whoat.net']);
_gaq.push(['_setAllowLinker', false]);
_gaq.push(['_gat._anonymizeIp']);
_gaq.push(['_trackPageview']);
// console.log('inside Analytics');
console.log(_gaq);
function init() {
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript';
var s = document.getElementsByTagName('script')[0];
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
s.parentNode.insertBefore(ga, s);
console.log(ga);
}());
}
//TRACK PAGE VIEWS
var trackPageView = function (url) {
//get the url from the pathname if it wasn't passed in
if (url === null || url === undefined) {
url = w.location.pathname;
}
//if an id is part of the url, replace the id with 'details'
url = url.replace(new RegExp(/\/[0-9]+$/), '/details');
_gaq.push(['_trackPageview', url]);
console.log('analytics trackPageView: '+url);
};
//TRACK SEARCH EVENT
var trackSearchEvent = function (searchTerm) {
var url = w.location.pathname;
url = url.replace(new RegExp(/\/[0-9]+$/), '/details');
_gaq.push(['_trackEvent', 'search', searchTerm, 'url for search is ' + url]);
console.log('analytics trackSearchEvent: '+searchTerm);
};
//TRACK VIDEO EVENT
var trackVideoEvent = function (event, videoID, time) {
var label;
if (time !== null && time !== undefined) {
label = 'video id is ' + videoID + " and time is " + time;
} else {
label = 'video id is ' + videoID;
}
_gaq.push(['_trackEvent', 'video', event, label]);
};
//track the page just landed on
trackPageView();
return {
trackPageView: trackPageView,
trackSearchEvent : trackSearchEvent,
trackVideoEvent : trackVideoEvent,
init : init
};
}(jQuery, window));
$(document).ready(function () {
WHOAT.analytics.init();
}); // document ready
我们的 Alpha 网站:http: //neytiri.whoat.net/
console.logs 读出,没有错误(除了 vimeo 一个)