Jump to content

Extension:GoogleTagManager

From mediawiki.org
MediaWiki extensions manual
GoogleTagManager
Release status: stable
Implementation User activity
Description Adds Google Tag Manager container for tracking
Author(s) Sophivorustalk
Latest version 1.1 (2023-09-21)
MediaWiki 1.39+
PHP 7.4+
Database changes No
License GNU General Public License 3.0 or later
Download
  • $wgGoogleTagManagerSkipGroups
  • $wgGoogleTagManagerContainerID
  • $wgGoogleTagManagerDefer
Quarterly downloads 8 (Ranked 122nd)
Public wikis using 5,867 (Ranked 113rd)
Translate the GoogleTagManager extension if it is available at translatewiki.net

The GoogleTagManager extension adds a Google Tag Manager container. You can then configure the container from https://tagmanager.google.com to insert other scripts such as Google Analytics, Hotjar, etc.

Installation

[edit]
  • Download and move the extracted GoogleTagManager folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleTagManager
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'GoogleTagManager' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]

Only $wgGoogleTagManagerContainerID is required. Each configuration option is shown along with its default value.

// Your Google Tag Manager container ID, e.g. GTM-XXXXXX
$wgGoogleTagManagerContainerID = "";

// Array of user groups that won't be tracked, e.g. [ 'sysop' ]
$wgGoogleTagManagerSkipGroups = [];

// Change this to run GTM only after the HTML is fully parsed
$wgGoogleTagManagerDefer = false;

See also

[edit]