Google Analytics Viewport Tracking
Google Analytics has tracked browser viewport sizes for almost four years, but I found it was imprecise. After doing some recent testing I have decided it works well and have started to dump my own tracking as a result.
This post shares some of the history and comparison information.
I have argued for years that designing web pages to specific screen sizes is a terrible idea. Not just because too many designers rely on pixel-perfect layouts, but also because designers rarely accounted for browser chrome (such as scrollbars).
When I say I have been arguing for years, I mean since at least 2000 when I wrote Real-World Browser Size Stats, Part I and Real-World Browser Size Stats, Part II (though I was definitely ranting on the evolt.org mailing list before that). In them I provided a script for grabbing and logging viewport sizes, and then compared those numbers across screen sizes.
In 2013 I shared a script on how to capture viewport sizes using Google Analytics in the post My Viewport Sizes. Now it was much easier to compare screen sizes and window sizes, and hopefully to make it easier to fold that into reports that end up in front of or informing designers.
I shared that script about six months after Google released the ability to look at browser sizes (what I call viewport sizes) in Google Analytics. While I had written my script a couple years earlier, I opted not to mention Google’s new offering since it was… inaccurate in my testing.
As I recently started making some updates to my site, I figured it was time to compare my numbers with what Google Analytics was reporting. I modified my script to use Universal Analytics and got to work capturing data.
From My Own Script
This is data pulled from an updated version (using the Universal Analytics syntax) of my own script.
From Google Analytics
This is generated from the Browser Size data available in Google Analytics.
Out of 500 data points, the following three came back from Google Analytics as
not set. For the chart above I set them to 0 × 0 instead of discarding the data points completely. The following table shows them. It is worth noting that often these data points are not proper user agents, and often correspond to bots.
|My script||Google Analytics||Browser|
|0 × 224||(not set)||Chrome 55.0.2883.91 on Android 7.1.1|
|1024 × 800||(not set)||UC Browser 184.108.40.206|
|0 × 0||(not set)||Android Webview, Android 6.0.1|
In an effort to show how the two sets of data compare, I have plotted them both into one chart using a questionable set of colors. For the most part, the difference is negligible for any use where you do not need pixel precision.