Last updated 7 July 2015. Created on 7 July 2015.
Edited by peterx. Log in to edit this page.

SEO, presentation, themes, they all depend on an understanding of who visits your site and what they use to view your site. Request statistics gives you a look at what they use to view your site.

SEO

Site owners and developers dive into complicated approaches to presenting sites on different browsers and multiple device formats without knowing exactly what is used on their site. SEO can suffer due to overly complex changes. Google now tests sites for responsive design. Responsive design is now one of the top three SEO priorities. Request statistics started as a way to find the most common device widths for responsive design optimisation.

Responsive design

One critical bit of information for responsive design is the width of the devices used to view your site and the width of the window used on larger screens. This package records and reports the width so you can focus on the requirements of your visitors.

Image size optimisation is a critical element when combining responsive design with fast response times on handheld devices. You want the smallest applicable image but do not want to create thousands of copies of every image in every size. Find the most commonly used sizes and create only those sizes.

Width, height, user agent

This package records what is used on your site, the height, width, and user agent. When the user resizes the window, you see the final size.

The information helps you make decisions about the resources you pour into your responsive design. Do you provide multiple image sizes to provide maximum image clarity while minimising download overheads? Yes, it is best practice. Now you can see the actual window sizes used to view your site and optimize the images with the minimum number of breaks.

Sample then report

The recording module is separate to the reporting module. You can switch recording on and off at any time then analyse the data forever. When you have enough data, you disable the recording module and use the view module to present the data in Views.

All recording systems slow down your site. You can see the long wait for Google analytics at the end of a page. Many of the statistics packages have the problem that you have to leave the recording overhead switched on while analysing the data.

We make life easier by separating data storage for recording. You switch the recording on for an hour or a day then switch the recording off. The data remains in the database while you analyse the information.

Data

There are two tables recording data. The Visitors table records the user id when the visitor is a logged in user. The Requests table records page and other requests. The two are linked for logged in users.

The Requests table records by year, month, day, and hour so you can analyse usage across the day and across the week plus include longer term trends.

You get inner height and width to look at what size display you can really use. You get outer height and width to see what is available when you can avoid scroll bars. You get the screen height and width to see what is potentially available if you could encourage people to expand their browser window.

The user agent string is included to give you an idea of the range of visitors plus the robots and everything else hitting your Web site. The user agent string is summarised as browser type, a virtual column containing desktop, mobile, or tablet.

Views

All the data is available in Views ready for your custom reports. The included reports are all views that you can clone to quick start your reports.

Views is included in Drupal 8 core so you might as well use it for everything in Drupal 7. The data appears as a standard table in Views with relationships to the user for page requests from logged in users. You could report almost anything. You might produce separate report for visits by users testing new devices.

Modules

This package contains three modules.

Request statistics

This is the base module required by the other two modules. This module creates the tables to store the data. Install this module when you want to start recording. Uninstall this module when you are finished reporting and want to throw away the data.

Request statistics record

Install this module, Request statistics record, when you want to start recording. Switch the module off to stop recoding and to stop the small overhead produced by the recording.

The data will remain available for viewing after you uninstall Request statistics record because the data is stored by Request statistics.

Request statistics view

Switch Request statistics view on to list the data through Views. This module includes default views to list every table, column, and row. You can add you own views for extra detail analysis.

You can contribute your views to this package by exporting the view and attaching the export to an issue.

Security

The recording Ajax URL is the only opening for an attacker and is only open when you record a sample of visitors. The URL could let an attacker insert extra rows in your database. Remember to switch off the record module when you finish recording your sample.

The request data contains nothing requiring security. Web site owners see the same user agents visiting every site. Someone could check your number of page hits through this data but you probably already use Google analytics and Google is already selling your Web site popularity to everyone.

The visitor data contains a user id to provide a relationship to the user table. You might want to limit access to the user usage patterns. Given that you will sample only an occasional few minutes, there is not enough data to develop a pattern of usage for a user.

Testing

The modules are in production use at three sites. The results created some confusion at one site because they were expecting everyone to be using an iPhone. iPhones are the most common device only in America. The Samsung Galaxy outnumbers iPhones in many other countries. For Web site access, tablets outnumber iPhones.

The views included in the Request statistics view module can be cloned to produce your own reports. You can also modify the supplied views but then the module cannot delete or replace the supplied views, you have to remove the modified views manually. Cloning is better than direct modification.

After you install, update, or replace Request statistics view, clear the cache to see the menu entries and the views.

Requesting extra data

The module records from Javascript to the database via an Ajax request to the module's PHP code. Anything can be added to the recording provided it is one request producing one database row. If Javascript can find the data, the data can be added as an extra field to the Ajax request. Simple data can be added to the database row.

If you want recording of complex structured data, you should first look at some of the other statistics modules. Recording of extra data through one request could also be achieved by an add-on module.

Continuous recording

Request statistics records samples of data. When you want continuous recording, you need extra protection against a denial of service attack through an overload of false entries. There are several ways to add protection and all of them run up against problems with front end cashes. Drupal 8 has some changes to reduce the problem. There is a complicated add-on module reducing the problem in Drupal 7 but the add-on module fights many problems and is difficult to configure.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.