Extension:GoogleTagManager

Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
GoogleTagManager
Release status: stableCategory:Stable extensions
Implementation User activity Category:User activity extensions
Description Adds Google Tag Manager container for tracking
Author(s) Sophivorustalk
Latest version 1.1 (2023-09-21)
MediaWiki 1.39+Category:Extensions with manual MediaWiki version
PHP 7.4+
Database changes No
License GNU General Public License 3.0 or later
Download Category:Extensions in Wikimedia version control
  • $wgGoogleTagManagerSkipGroups
  • $wgGoogleTagManagerContainerID
  • $wgGoogleTagManagerDefer
Quarterly downloads 3 (Ranked 93rd)
Public wikis using 5,867 (Ranked 113rd)
Translate the GoogleTagManager extension if it is available at translatewiki.net
Category:All extensions

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

  • 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

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

Category:Google extensions
Category:All extensions Category:BeforePageDisplay extensions Category:Extensions in Wikimedia version control Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:Google extensions Category:ResourceLoaderGetConfigVars extensions Category:Stable extensions Category:User activity extensions