Last updated August 27, 2010. Created by ghankstef on October 13, 2001.
Edited by batigolix, LeeHunter, Stoob, add1sun. Log in to edit this page.
The Statistics module shows you how often a given page is viewed, who viewed it, the previous page the user visited (referrer URL), and when it was viewed. These statistics are useful in determining how users are visiting and navigating your site. For more information, see the online handbook entry for the Statistics module.
Use
Configuring statistics
In Drupal 7 configure statistics via configuration > statistics.
In Drupal 6 configure statistics via administer > reports > access log settings.
In Drupal 5 configure statistics via administer > logs > access log settings.
To enable collection of statistics, the Enable access log checkbox on the Statistics settings page must be checked. This access log is used to store data about every page accessed, such as the remote host's IP address, where they came from (referrer), what node they've viewed, and their user name. Enabling the log adds one database call per page displayed by Drupal.
The Discard access logs older than setting on the settings page specifies the length of time entries are kept in the log before they are deleted. This setting requires a correctly configured cron maintenance task to run.
Enable Count content views to turn on and off the node-counting functionality of this module. If it is turned on, an extra database query is added for each node displayed, which increments a counter.
Viewing site usage
The Statistics module can help you break down details about your users and how they are using the site. The module offers four reports:
- Recent hits displays information about the latest activity on your site, including the URL and title of the page that was accessed, the user name (if available) and the IP address of the viewer.
- Top referrers displays where visitors came from (referrer URL).
- Top pages displays a list of pages ordered by how often they were viewed.
- Top visitors shows you the most active visitors for your site and allows you to ban abusive visitors.
Displaying popular content
The module includes a Popular content block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable Count content views on the statistics settings page, and then you can enable and configure the block on the blocks administration page.
Page view counter
The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable Count content views on the statistics settings page, and set the necessary permissions (View content hits) so that the counter is visible to the users.
Statistics administration pages
Permissions
To access statistics one needs the proper permissions.
Comments
Top Visitors report provides hostname rather than visitor stats
The function that produces the Top Visitors report (modules/statistics/statistics_admin.inc -> statistics_top_visitors()) groups visitor stats first by hostname then by uid effectively producing hostname stats rather than visitor stats.
If a user logs in from a number of different hostnames/IP addresses (or if the visitor's ISP routinely assigns the user different IP addresses), the user's stats are broken out separately for each hostname/IP address the user logged in from. The result is that the report then gives you the highest number of visits from a given hostname rather than from a given visitor. This is misleading. In order to get top visitors, you'd have to total the separate stats for each user manually.
The query:
<?php$sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM {accesslog} a LEFT JOIN {access} ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, ac.aid". tablesort_sql($header);
?>
should be changed to:
<?php$sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM {accesslog} a LEFT JOIN {access} ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.uid, u.name, ac.aid". tablesort_sql($header);
?>
to provide actual visitor stats.
This should be put in the issue Queue
James, please open a Drupal 8 issue for this concern -> http://drupal.org/project/issues/drupal
That is where something like this would be adressed and not in the docs here.
--
OpenConcept | Twitter @mgifford