Extension:Analytics
Analytics Release status: beta |
|
---|---|
Implementation | Special page |
Description | Traffic and edit analytics for the entire wiki, as well as specific categories and pages |
Author(s) | Sophivorustalk |
Latest version | 1.0 (2024-07-29) |
MediaWiki | 1.39+ |
PHP | 8+ |
Database changes | Yes |
License | GNU General Public License 3.0 or later |
Download | |
Example | Appropedia |
|
|
Quarterly downloads | 24 (Ranked 116th) |
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:
- A special page called Special:Analytics where you can explore freely through a simple UI (example)
- A Lua library called mw.ext.analytics that exposes the data to Lua modules and templates (example)
- A REST API endpoint called /analytics that exposes the data to other software and scripts (example)
Installation
[edit]- 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 task T173141 for potential complications.) - 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
[edit]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. 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 want to set $wgAnalyticsCountPageViews = false;
in your LocalSettings.php to disable the default tracking of pageviews.
See also
[edit]- 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
- Beta status extensions
- Special page extensions
- GPL licensed extensions
- Extensions in Wikimedia version control
- LoadExtensionSchemaUpdates extensions
- PageViewUpdates extensions
- ScribuntoExternalLibraries extensions
- All extensions
- Extensions requiring Composer with git
- Web Analytics extensions
- Statistics extensions