我正在使用vanilla ga异步代码,就在结束之前</head>:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-1']);
_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);
})();
</script>
</head>
Run Code Online (Sandbox Code Playgroud)
现在,稍后在页面中间我打电话:
<script>
_gaq.push(['_setCustomVar',
1,
'usertype',
'anon',
2
]);
</script>
Run Code Online (Sandbox Code Playgroud)
问题是,我是否需要再次调用_trackPageView?
也就是说,我应该添加另一个
_gaq.push(['_trackPageview']);
...?
是的,你需要再打一次电话_trackPageView来计算_setCustomVar.但是,这将计为2个单独的页面视图,这将扩大页面的页面视图数.因此,您应该将_setCustomVar之前移动到之前_trackPageView调用.
| 归档时间: |
|
| 查看次数: |
4247 次 |
| 最近记录: |