Extension:Analytics
![]() Release status: stableCategory:Stable extensions |
|
---|---|
Implementation | Special pageCategory:Special page extensions |
Description | Traffic and edit analytics for the entire wiki, as well as specific categories and pages |
Author(s) | Sophivorustalk |
Latest version | 1.2 |
MediaWiki | 1.39+Category:Extensions with manual MediaWiki version |
PHP | 8+ |
Database changes | Yes |
License | GNU General Public License 3.0 or later |
Download | Category:Extensions in Wikimedia version control |
Example | Appropedia |
|
|
Quarterly downloads | 18 (Ranked 80th) |
Translate the Analytics extension if it is available at translatewiki.net |
The Analytics extension gives access to traffic and edit analytics for the entire wiki, as well as for specific categories and pages, in three ways:
Installation
- Download and move the extracted
Analytics
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Analytics - Only when installing from Git, run Composer to install PHP dependencies, by issuing
composer install --no-dev
in the extension directory. (See T173141 for potential complications.)Category:Extensions requiring Composer with git - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Analytics' );
- Run the update script which will automatically create the necessary database tables that this extension needs.
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Tracking page views
When installed, this extension will create a database table called analytics_pageviews
and will start tracking the daily pageviews to each page.
However, if you're installing this extension some time after your wiki started, then the pageviews table will lack historical data.
If you've been using Google Analytics (GA4), you can use the maintenance script bundled with this extension to populate the pageviews table with the historical data, like so:
php /path/to/w/maintenance/run.php /path/to/w/extensions/Analytics/maintenance/populatePageViewsFromGA4.php --credentials /path/to/google-cloud-credentials.json --property 123456789
Furthermore, if your wiki is using a proxy (like Cloudflare), then many or even most of your pageviews will not reach your server, which means this extension won't be able to track them.
To work around this, if you're using GA4, run the maintenance script with --days 1
using a daily cronjob to keep your pageviews table up to date.
If you do, you may also want to set $wgAnalyticsCountPageViews = false;
in your LocalSettings.php to disable the default tracking of pageviews.
See also
- Extension:HitCounter - Tracks the total page views of each page
- Extension:UserPageViewTracker - Tracks who visited which page, how many times and when was the last visit