Extension:GoogleAnalyticsMetrics

From mediawiki.org
This page is a translated version of the page Extension:GoogleAnalyticsMetrics and the translation is 100% complete.
This extension is professionally maintained by the WikiTeq team.
WikiTeq provides official support for MediaWiki LTS releases only. It may work with other MediaWiki releases.
MediaWiki 拡張機能マニュアル
GoogleAnalyticsMetrics
リリースの状態: 安定
実装 パーサー関数
説明 Google Analytics のアクセス解析を取得します。
作者 Ike Hecht (Tosfosトーク)
メンテナー WikiTeq team
最新バージョン 1.0.2 (2023年1月)
互換性の方針 長期間サポート リリースであるすべての MediaWiki リリースについて、拡張機能に対応するブランチが存在します。
MediaWiki 1.35, 1.39
データベースの変更 いいえ
Composer mediawiki/google-analytics-metrics
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgGoogleAnalyticsMetricsViewId
  • $wgGoogleAnalyticsMetricsExpiry
  • $wgGoogleAnalyticsMetricsAllowed
Quarterly downloads 6 (Ranked 134th)
translatewiki.net で翻訳を利用できる場合は、GoogleAnalyticsMetrics 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

GoogleAnalyticsMetrics は Google Analytics のアクセス解析を取得し、パーサー関数を用いてウィキ ページにその結果を挿入します。この拡張機能は WikiWorks のために作成されました。

The GoogleAnalyticsMetrics extension may not be appropriate for your site if you have data security and privacy concerns. The extensions inserts JavaScript code in each page served, and the code causes the client to contact Google services to process and aggregate data. Your site's users will be subjected to tracking and data mining regardless of the Do Not Track or Global Privacy Control browser settings.

インストール

  • Setup Google Analytics API by following Step 1 here
  • Install the Google Client Library by following Step 2 here
  • Enable Google Analytics Reporting API in your Google Cloud Console
  • ダウンロードして、ファイルをextensions/フォルダー内のGoogleAnalyticsMetricsという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleAnalyticsMetrics
  • Gitでのインストールの場合のみ、PHPの依存関係をインストールするためComposerを実行します。 (合併症の可能性についてはタスク T173141を参照。)
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'GoogleAnalyticsMetrics' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

使用法

googleanalyticsmetrics パーサー関数は 3 つのパラメーターを取り、以下の形式です:

{{#googleanalyticsmetrics: metric=メトリック名|page=ページ名|startDate=開始日|endDate=終了日}}
メトリック名
The name of the Google Analytics Metric that should be displayed. The full list of Google Analytics metrics is here. Omit the ga: prefix.
ページ名
The name of the page. This parameter is only used when the metric is a per page metric.
開始日
Show the metric since this date (optional). Defaults to 2005-01-01, which is the beginning of time according to Google Analytics.
終了日
Show the metric until this date (optional). Defaults to today.

開始日と終了日のパラメータは "Year-Month-Day" の形式を用います。

これは開始日から終了日までのサイトページの閲覧数が表示される例を示しています。

{{#googleanalyticsmetrics: metric=pageviews}}

2011年2月3日からのセッション数を表示します。

{{#googleanalyticsmetrics: metric=session|startDate=2011-02-03}}

2012年2月1日までの平均セッション継続時間を表示します。

{{#googleanalyticsmetrics: metric=avgSessionDuration|endDate=2012-02-01}}

ParserFunctions 拡張機能の機能を用いて、先月までのページ閲覧数のみを表示します:

{{#googleanalyticsmetrics: metric=pageviews|startDate={{#time:Y-m-d|先月の初日}}|endDate={{#time:Y-m-d|今月の初日}}}}

上記の例をよりよく記述する場合

{{formatnum:{{#googleanalyticsmetrics: metric=pageviews|startDate={{#time:Y-m-d|先月の初日}}|endDate={{#time:Y-m-d|今月の初日}}}}}}

Show the number of page views for a page, from the beginning until the end of time:

{{#googleanalyticsmetrics: metric=pageviews|page=Main_Page}}

See this page for some help with formatting this extension's output.

There is also a {{#googleanalyticstrackurl:http://urlhere|link text}} function but it only works if the ga js library has already been loaded.

構成パラメーター

$wgGoogleAnalyticsMetricsAllowed
An array containing the name of Google Analytics metrics that are allowed to be retrieved by the extension. Defaults to *, which allows all metrics.
$wgGoogleAnalyticsMetricsEmail
The email address of the Google Analytics account.
$wgGoogleAnalyticsMetricsPath
Path to your certificate key file.
$wgGoogleAnalyticsMetricsViewId
Google Analytics View ID.

関連項目