MediaWiki extensions manual
GTag
Release status: stable
Implementation User activity
Description Add Google Analytics tracking to pages
Author(s) Skizzerztalk
Latest version 1.2.0 (2020-10-12)
Compatibility policy Master maintains backward compatibility.
MediaWiki 1.34+
Database changes No
License MIT License
Download
Parameters
  • $wgGTagAnalyticsId
  • $wgGTagAnonymizeIP
  • $wgGTagHonorDNT
  • $wgGTagTrackSensitivePages
Added rights
gtag-exempt
Hooks used
  • BeforePageDisplay

The GTag extension lets you insert the new Google Analytics tracking tag on your MediaWiki site ("gtag.js").

Download

This extension can be downloaded as a .tar.gz file, here (you must first register on mwusers.org in order to download the file).

You can also download the extension via Git from its GitHub repository, by calling the following:

git clone https://github.com/SkizNet/mediawiki-GTag/

Installation

  • Download and place the file(s) in a directory called GTag in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'GTag' );
    $wgGTagAnalyticsId = 'UA-xxxxxxxxx-x' or 'G-XXXXXXXX'; // replace this with your Google Analytics id
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration parameters

$wgGTagAnalyticsId (string)
Google Analytics id, required.
$wgGTagAnonymizeIP (boolean, default false)
If true, anonymize the IP address sent to Google Analytics.
$wgGTagHonorDNT (boolean, default true)
If true, honor "Do Not Track" requests from browsers. If false, ignore such requests.
$wgGTagTrackSensitivePages (boolean, default true)
If true, insert tracking code into sensitive pages such as Special:UserLogin and Special:Preferences. If false, no tracking code is added to these pages.

User rights

gtag-exempt
Users granted this right will not be tracked by Google Analytics. This can be useful to exempt staff groups from being tracked, to get a better idea of what your end users are doing on the wiki.

See also

  • Extension:Google Analytics Integration - Provides similar features although it uses a different/older Google Analytics API to perform tracking. The GTag extension makes use of the newer Google Site Tag feature to perform tracking.
This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.