Extension:GTag
Appearance
Release status: stable |
|
|---|---|
| Implementation | User activity |
| Description | Add Google Analytics tracking to pages |
| Author(s) | Skizzerztalk |
| Latest version | 1.4.0 (2025-07-17) |
| Compatibility policy | Master maintains backward compatibility. |
| MediaWiki | 1.43+ |
| PHP | 8.1+ |
| Database changes | No |
| License | MIT License |
| Download | GitHub: |
|
|
|
gtag-exempt |
|
The GTag extension lets you insert the new Google Analytics tracking tag on your MediaWiki site ("gtag.js"). It also supports using a GTM ID to insert a Google Tag Manager container instead of the gtag.js tracker, for those who use Google Tag Manager.
Download
[edit]- Download a .zip of the most recent extension version (compatible with MediaWiki 1.39+)
- Clone the extension via git into your wiki's extensions directory:
git clone https://github.com/SkizNet/mediawiki-GTag GTag
Installation
[edit]- Download and place the file(s) in a directory called
GTagin yourextensions/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
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration parameters
[edit]- $wgGTagAnalyticsId (string)
- Google Analytics ID or Google Tag Manager container ID, for example
'GT-NNVDXRX5'or'GTM-MG9RFZQQ'. Required. - $wgGTagAnonymizeIP (boolean, default false)
- If true, anonymize the IP address sent to Google Analytics. Ignored when operating in Google Tag Manager mode.
- $wgGTagEnableTCF (boolean, default false)
- If true, support the IAB Transparency & Consent Framework used by many 3rd party cookie consent widgets. You will need to implement such a widget yourself into your wiki; the extension does not come with one. Ignored when operating in Google Tag Manager mode.
- $wgGTagHonorDNT (boolean, default false)
- 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
[edit]- 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
[edit]- 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.
- Extension:GoogleTagManager
| This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
