Google analytics GA仪表板中未跟踪自定义变量
我在javascript中使用了所有页面都可以访问的自定义变量,下面是我的GA跟踪代码,紧跟在唯一一个名为index.html的页面的结束头标记之前Google analytics GA仪表板中未跟踪自定义变量,google-analytics,Google Analytics,我在javascript中使用了所有页面都可以访问的自定义变量,下面是我的GA跟踪代码,紧跟在唯一一个名为index.html的页面的结束头标记之前 var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-33766550-1']); var currentCountry = 'N/A'; if (localStorage.getItem('country')) {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33766550-1']);
var currentCountry = 'N/A';
if (localStorage.getItem('country')) {
currentCountry = localStorage.getItem('country');
}
_gaq.push(['_setCustomVar', 1, 'Country', currentCountry]);
_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);
})();
GA追踪对我来说很好。
到目前为止,我只能跟踪一个自定义变量,该变量已在标题部分country(如上所示)的主跟踪代码中定义
我在javascript文件中使用的其他自定义变量(这个js在index.html中总是可以访问)似乎根本没有被调用。此js文件包含用于不同自定义变量的不同_gaq.push命令,如下所示
_gaq.push([''u setCustomVar',5',Page','app/index.html''portfolioDetailPage'])
问:为什么我不能在GA中跟踪这些自定义变量,而不像我在主跟踪代码中传递的“country”自定义变量?
我是否需要在自定义变量声明的每个_gaq.push之后传递_gaq.push([''u trackPageview'])
谁能告诉我,我现在一团糟:(
谢谢您缺少范围参数。请仔细检查
\u setCustomVar
的签名
谢谢Eduardo。我可能输入了错误的代码,实际上我使用的是正确的代码。我使用自定义变量进行跟踪,而在我的场景中,事件跟踪更有意义 如果(_gaq)_gaq.push(['''u trackEvent','Page','Home\u Page''u Landing','app/index.html']) 谢谢