Page View Statistic for ProcessWire

Page View Statistic for ProcessWire is a module to log page views of the CMS. The records including some basic information like IP-address, browser, operating system, requested page and originate page. This module doesn't claim to be the best or most accurate. But it offers a special feature that you can't find everywhere.

Advantages
One of the biggest advantage is that this module doesn't require any external service like Google Analytics or similar. You don't have to modify your templates either. There is also no Javascript or image required.

Disadvantages
There is only one disadvantage. This module doesn't record visits if the browser loads the page from its browser cache. To prevent the browser from loading the page from its cache, add the following meta tags to the header of your page:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

How to use
The records can be accessed via the Setup-menu of the CMS backend. The first dropdown control changes the view mode.

View mode

Detailed records
View mode "Detailed records" shows all visits of the selected day individually with IP-address, browser, operating system, requested page and originate page. Click the update button to see new added records.

Detailed records

Cached visitor records
View modes other than "Detailed records" are cached visitor counts. Cached visitor records are collected on a daily basis from the detailed records. This approach is new in version 1.0.8 and ensures fast display even with many records. Another advantage is that the detailed records can be deleted while the cache remains. The cache can be updated manually or automatically in a specified time period. Multiple visits from the same IP address on the same day are counted as a single visitor.

Cached visitor records

Upgrade from older versions
Cached visitor counts is new in version 1.0.8. If you just upgraded from an older version you might expire a delay or even an error 500 if you display cached visitor counts. The reason for this is that the cache has to be created from the records. This can take longer if your database contains many records. Sometimes it might hit the maximally execution time. Don't be worry about that and keep reloading the page until the cache is completely created.

Upgrades in general
It seems that the upgrade function don't get called after an upgrade. This might be a bug in ProcessWire. This can lead to an error message ("Unknown column...") if you try to open the statistic page immediately after an upgrade. There are two ways to avoid this error message. Click the "Continue to module settings" button directly after the upgrade or open the Modules page and click the "Refresh" button.

Time of view
This module can record the time a visitor viewed the page. This feature is deactivated by default. To activate open the module configuration page and activate "Record view time". If activated you will find a new column (S.) in the records which means the time of view in seconds. With every page request, a Javascript code is added directly after the <body> tag. Every time the visitor switches to another tab or closes the tab, this script reports the number of seconds the tab was visible. The initial page request is recorded only as a hyphen (-).

Time of view

Execution time
Starting with version 1.1.9 this module records the PHP execution time from the initialization of the module till the HTML output in seconds.

Execution time

Settings
You can access the module settings by clicking the Configuration button at the bottom of the records page. The settings page is also available in the menu: Modules->Configure->ProcessPageViewStat.

IP2Location
This module uses the IP2Location database from: https://www.ip2location.com. This database is required to determinate the country of the IP address. IP2Location updates this database at the begin of every month. The settings of ProcessPageViewStat offers the ability to automatically download the database monthly. Please note, that automatically download will not work if your webspace doesn't allow allow_url_fopen.

Dragscroll
This module uses DragScroll, a JavaScript available from: https://github.com/asvd/dragscroll. Dragscroll adds the ability in view mode "Day" to drag the records horizontally with the mouse pointer in desktop browsers.

PhpUserAgent
This module uses PhpUserAgent available from: https://github.com/donatj/PhpUserAgent. PhpUserAgent is required to filter out the browser type and platform from the server request.

geoPlugin and OpenStreetMap
This module uses geoPlugin and OpenStreetMap. The location is determined using the free service geoPlugin. The map will be generated with layers from OpenStreetMap.

New in version 1.1.0
A new feature in version 1.1.0 offers the possibility to record user names of logged in visitors. Just activate "Record user names" and "Record loggedin user" in the module settings.

New in version 1.1.3
A new feature in version 1.1.3 offers an internal WHOIS function. In the module settings you can switch between internal and external WHOIS.

WHOIS

New in version 1.1.4
Detailed records can now be exported as CSV-file. The file contains all data of the specified date regardless of the pagination. The button is located at the bottom of the page.

New in version 1.1.8
The UserAgentParser was exchanged with PhpUserAgent due to some complaints.

Donate

Download:

Change log:

  • Version 1.0.1: Initial version
  • Version 1.0.2: Added namespace
  • Version 1.0.3: Minor change in code
  • Version 1.0.4: Minor change in code
  • Version 1.0.5: Solves a bug with month names
  • Version 1.0.6: Solves a problem with database requests
  • Version 1.0.7: Some improvements
  • Version 1.0.8: Added caching of visitor counts
  • Version 1.0.9: Some improvements
  • Version 1.1.0: Added "Record user names"
  • Version 1.1.1: Updated parseUserAgentStringClass
  • Version 1.1.2: Some improvements
  • Version 1.1.3: Added internal WHIOS
  • Version 1.1.4: Added CSV export
  • Version 1.1.5-1.1.7: Some improvements
  • Version 1.1.8: UserAgentParser exchanged with PhpUserAgent
  • Version 1.1.9: Added calculation of the PHP execution time
  • Version 1.2.0: Some improvements
  • Version 1.2.1: Added map showing the location of the IP address
  • Version 1.2.2: Replaced str_starts_with() with substr() to support PHP7
  • Version 1.2.3: Solved a bug with MySql8
Published: 10. Aug 2020
Categories: PHP ProcessWire Javascript CMS