apr*_*ion 3 javascript google-analytics
我正在尝试在Google Analytics中获取setAllowAnchor标记以记录广告系列信息,但它似乎无法正常工作.
我正在尝试使用它的网站使用hashbang风格的网址BTW - 这http://hostname/#!/relative-url是导航风格,因为需要跨页面视图的持久音频播放器.
我已尝试过以下两种方法,但我没有setAllowAnchor在GA中看到任何广告系列.
/#!/&utm_campaign=setAllowAnchor&utm_medium=hash&utm_source=test
/#utm_campaign=setAllowAnchor&utm_medium=hash&utm_source=test
Run Code Online (Sandbox Code Playgroud)
不推荐使用函数setAllowAnchor.我究竟做错了什么?
我的Google Analytics代码如下所示:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1060190-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
_gaq.push(['_setAllowAnchor', true]);
(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>
Run Code Online (Sandbox Code Playgroud)
任何Google Analytics配置都必须在该功能_trackPageview或任何其他_track*功能之前.因此,如果您重写代码以_setAllowAnchor在_trackPageview它应该工作之前发出它.
还要注意_trackPageLoadTime不再需要了.它是默认发布的,因此不推荐使用该函数.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1060190-1']);
_gaq.push(['_setAllowAnchor', true]);
_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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2361 次 |
| 最近记录: |