Collect site statistics
This recipe explains how to install and enable the core statistics module, and how to inspect the page view-counter and a block that displays popular content.
Table of contents
- Introduction
- Installing and enabling statistics
- Display page views-counter
- Display popular content
- Notes
Introduction
If you want to have a page views-counter on your website to get a rough idea about the number of page views your contents get, or display lists of popular content, you can use the core Statistics module.
The module provides two ways to display the statistics data:
- A page views-counter that shows how many times a particular page has been viewed.
- A "Popular content"-block that may be placed in a region.
European privacy regulation (GDPR) requires consent for the collection of information that links personal information such as the visitor's IP-address to page views. To protect the privacy of the visitors to your site, the Statistics module does not collect this and therefore, it cannot display demographic data.
Installing and enabling statistics
The Statistics module is in core, but unistalled by default. To install, navigate to
and locate "Statistics" in the list of modules available. Place a checkmark in the checkbox to the left of the name. Then scroll down to the bottom of the page and click "Install".To enable collection of statistics, navigate to
, and check the "Count content views" checkbox.Display page views-counter
The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, first enable statistics as described above.
To control visibility, navigate to
, and locate the permissions ("View content hits") in the "Statistics" section of the page. Give it to the roles that shall see the counter (usually only "Administrator").The counter will not be displayed if the count is zero. Make sure you've have at least one view of a page before you look for it.
You may have to clear the cache to see the counter. Navigate to
and press "Clear all caches".Display popular content
The module provides a "Popular content"-block that may displays these three statistics lists:
- most viewed pages today
- most viewed pages for all time
- last content viewed
To show the block, first enable statistics as described above, then:
- Navigate to .
- Decide in what region to place the block and click ("Place block") for that region.
- Locate the block "Popular content" and click "Place block"
- Configure how many results to show for each statistics list.
- Configure the visibility of the block.
Notes
To save resources, the visible page views-counter and "Popular content" block is only updated when the cache is cleared.
Last update: 2021-02-21.