我们正尝试在Google Analytics中捕获实际浏览器窗口大小的报告.我知道他们已经进行了页内分析,但这并不提供数据,只提供可视化.任何人都知道我们是否遗漏了什么,或者我们是否需要将其添加为自定义事件?
这真的有必要吗?
<script type="text/javascript">
var width = window.innerWidth || document.body.clientWidth;
var height = window.innerHeight || document.body.clientHeight;
width = Math.round(width/100)*100;
height = Math.round(height/100)*100;
var size = width + "x" + height;
_gaq.push(['_trackEvent', 'Browser Size', 'Range', size]);
</script>
Run Code Online (Sandbox Code Playgroud)
小智 6
您需要添加自定义事件.我尝试了你的javascript,但它与Google Analytic的跳出率相混淆.您需要将opt_noninteraction变量传递为"true",否则Google会将该事件视为用户交互.跟踪浏览器窗口大小不是用户交互,应从跳出率calc中排除.
这是修改后的代码:
<script>
var width = window.innerWidth || document.body.clientWidth;
var height = window.innerHeight || document.body.clientHeight;
width = Math.round(width/10)*10;
height = Math.round(height/10)*10; //Using a 10 pixel granularity
var size = width + "x" + height;
_gaq.push(['_trackEvent', 'Browser Size', 'Range', size,, true]); //don't count in Bounce Rate
</script>
Run Code Online (Sandbox Code Playgroud)