MediaWiki添加Google Analysis

跳到导航 跳到搜索


  • 下载 下载 我选择 比我的mv版本高一点点的版本 Download and place the file(s) in a directory called googleAnalytics in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/googleAnalytics/googleAnalytics.php";
// Replace xxxxxxx-x with YOUR GoogleAnalytics UA number
$wgGoogleAnalyticsAccount = 'UA-18180817-2'; 

// Optional configuration (for defaults see googleAnalytics.php)

// Add HTML code for any additional web analytics (can be used alone or with $wgGoogleAnalyticsAccount)
$wgGoogleAnalyticsOtherCode = '<script type="text/javascript" src=""></script>';

// Store full IP address in Google Universal Analytics (see for details)
$wgGoogleAnalyticsAnonymizeIP = true; 

// Array with NUMERIC namespace IDs where web analytics code should NOT be included.
$wgGoogleAnalyticsIgnoreNsIDs = [

// Array with page names (see magic word {{FULLPAGENAME}}) where web analytics code should NOT be included.
$wgGoogleAnalyticsIgnorePages = [
// Array with special pages where web analytics code should NOT be included.
$wgGoogleAnalyticsIgnoreSpecials = [
// Use 'noanalytics' permission to exclude specific user groups from web analytics, e.g.
$wgGroupPermissions['sysop']['noanalytics'] = true;
$wgGroupPermissions['bot']['noanalytics'] = true;

// To exclude all logged in users give 'noanalytics' permission to 'user' group, i.e.
$wgGroupPermissions['user']['noanalytics'] = true;

 vim  extensions/googleAnalytics/googleAnalytics.php 
 $wgGoogleAnalyticsAccount = "UA-18180817-2";
$wgGoogleAnalyticsAddASAC = false;
$wgGoogleAnalyticsIgnoreSysops = true;
$wgGoogleAnalyticsIgnoreBots = true;


#查看到 这个要不要加上 (UA-18180817-1) (UA-18180817-2)



WordPress配置谷歌分析(Google Analytics)和Search Console(GSC)教程

see also

MediaWiki添加Google Analysis统计代码方法