By Craig Buckler

Why Your Website Statistics Reports Are Wrong, Part 2

By Craig Buckler
Last chance to win! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

web site statistics pie chartIn my first post, we examined the advantages and disadvantages of server-side data collection and analysis. Although the generated reports can be useful, they have their flaws. Today, we look at the alternative…

Client-side Data Collection and Analysis

Client-side data collection requires an image or JavaScript code to be inserted on every page you want to analyze. The popularity of image counters has waned because they can only provide basic page hit information. JavaScript code can achieve more and is used by Google Analytics, one the most popular statistical reporting systems.

JavaScript runs whenever the page loads in your browser so it can overcome many of the caching issues experienced by server-side data collection. The code can also collect more detailed client information, e.g. the time spent on a page, mouse activity, clicked links, the screen resolution, color depth, browser window size, installed plugins, etc. Cookies may also be used to identify unique users and reveal navigation paths. Ultimately, the JavaScript code sends data to a back-end server for processing.

Unfortunately, there are several drawbacks:

JavaScript and cookies can be disabled or blocked. In general, you can expect around 5% to not run JavaScript, but this will differ from site to site. Similarly, search engine bots do not run JavaScript so the reports can never tell you if or when your site was indexed. The report may make an allowance for the missing users but it’s only a guess.

Dodgy code
JavaScript is fragile: if another script on your page causes a fatal error it could prevent data collation. Perhaps worse is that you could have a script which fails in just one browser; if your report indicates there are no Internet Explorer users is it because they were never recorded?

Page problems
JavaScript can analyze almost any aspect of the user’s page interaction, but the code could cause other scripts to break or run slowly. Most systems therefore take a conservative approach and only record basic details shortly after the page has loaded.

HTML pages only
It is only possible to analyze web pages which return HTML — the systems can not record CSS, images, MP3 or PDF file access. Google Analytics allows you to add on-click handlers to file download links, but there is no guarantee users will click them (they could receive the file URL via an email).

Human error
Script code must be manually added to every page you want to monitor. If you accidentally omit a page, it will never be recorded in your reports.

No historical data
Statistics can only be recorded from the point the script is added: it is not possible to generate historical reports.

Security risks
Linking to third-party JavaScript code is risky. It’s certainly inadvisable to use such systems on secure pages collecting private data.

Although many client-side analyzers produce great-looking and informative reports, the data collection process is inherently more volatile than server-side methods.

In the final post, we look at global statistics systems and summarize when, where, and how statistics can be useful.

Login or Create Account to Comment
Login Create Account
Get the most important and interesting stories in tech. Straight to your inbox, daily.
Is it good?Is it good?