We're trying to capture a report of actual browser window size in Google Analytics. I know they've got their in-page analytics, but that doesn't provide data, just a visualization. Anyone know if we're missing something or if we need to add this as a custom event?
Is this really necessary?
<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>
You do need to add a custom event. I tried the javascript you had, but it messed with Google Analytic's Bounce Rate. You need to pass the opt_noninteraction variable as "true", otherwise Google considers the event a user interaction. Tracking the browser window size is not a user interaction and should be excluded from the bounce rate calc.
Here is the modified code:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With