Extension:Google Analytics Integration

This page is a translated version of the page Extension:Google Analytics Integration and the translation is 41% complete.
MediaWiki 拡張機能マニュアル
Google Analytics Integration
リリースの状態: 安定
実装 利用者アクティビティ , フック
説明 MediaWikiページの下部にGoogleユニバーサル アナリティクス(または他のウェブ解析)のトラッキングコードを自動的に挿入します。
作者 Tim Laqua, Dāvis Mošenkovs
最新バージョン 3.0.1 (2017-10-29)
MediaWiki 1.23+
PHP 5.4+
データベースの変更 いいえ
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
Davis Mosenkovsによるプロジェクト(ページ下部にてソースを表示)

  • $wgGoogleAnalyticsAccount
  • $wgGoogleAnalyticsOtherCode
  • $wgGoogleAnalyticsAnonymizeIP
  • $wgGoogleAnalyticsIgnoreNsIDs
  • $wgGoogleAnalyticsIgnorePages
  • $wgGoogleAnalyticsIgnoreSpecials
  • noanalytics
Public wikis using 1,302 (Ranked 194th)
Google Analytics Integration 拡張機能の翻訳にご協力ください

Google Analytics Integration拡張機能は、Googleユニバーサルアナリティクス(または他のウェブ解析)のトラッキングコードを、閲覧したすべてのページに挿入するものです。 特定のページ、名前空間、特別ページ、特定の利用者グループのすべてのページを除外する設定が可能です。

この拡張機能は、あなたのニーズに対して古くなっている可能性があります。Google Analyticsの新しいグローバルサイトタグを使用している場合は、代わりにExtension:HeadScriptを使用してみてください。

Alternatively you can put Google Analytics tag directly into MediaWiki:Common.js of your wiki.

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のgoogleAnalyticsという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/googleAnalytics
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    require_once "$IP/extensions/googleAnalytics/googleAnalytics.php";
    // xxxxxxx-xをあなたのGoogleAnalyticsのUA番号に置き換えてください。
    $wgGoogleAnalyticsAccount = 'UA-xxxxxxx-x'; 
    
    // 省略可能な設定 (既定値は googleAnalytics.php を参照)。
    
    // 追加のウェブ解析のためのHTMLコードを追加する(単独もしくは$wgGoogleAnalyticsAccountと一緒に使うことができる)
    $wgGoogleAnalyticsOtherCode = '<script type="text/javascript" src="https://analytics.example.com/tracking.js"></script>';
    
    // Store full IP address in Google Universal Analytics (see https://support.google.com/analytics/answer/2763052?hl=ja for details)
    $wgGoogleAnalyticsAnonymizeIP = true; 
    
    // Array with NUMERIC namespace IDs where web analytics code should NOT be included.
    $wgGoogleAnalyticsIgnoreNsIDs = [
        500
        ];
    
    // Array with page names (see magic word {{FULLPAGENAME}}) where web analytics code should NOT be included.
    $wgGoogleAnalyticsIgnorePages = [
        'PageName',
        'NamespaceName:PageName'
        ];
        
    // Array with special pages where web analytics code should NOT be included.
    $wgGoogleAnalyticsIgnoreSpecials = [
        'Userlogin',
        'Userlogout',
        'Preferences',
        'ChangePassword',
        'OATH'
        ];
        
    // 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 the 'user' group, i.e.
    $wgGroupPermissions['user']['noanalytics'] = true;
    
  •   完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
The following options were removed in version 3.0.0:
  • $wgGoogleAnalyticsAddASAC
  • $wgGoogleAnalyticsIgnoreSysops
  • $wgGoogleAnalyticsIgnoreBots

使用法

  1. Create a Google Analytics account.
  2. Locate your UA number.
    • For the legacy code block, it can be found on the following line:
      _uacct="UA-xxxxxxx-x";
      
    • For the new ga.js code block, it can be found on the following line:
      var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
      
  3. Follow installation instructions.
  4. Google Analytics stats should start populating within 24-48 hours.

関連項目