Erweiterung:GoogleAnalyticsMetrics

This page is a translated version of the page Extension:GoogleAnalyticsMetrics and the translation is 70% complete.
Diese Erweiterung wird vom WikiTeq-Team professionell gewartet.
WikiTeq provides official support for MediaWiki LTS releases only. It may work with other MediaWiki releases.
MediaWiki-Erweiterungen
GoogleAnalyticsMetrics
Freigabestatus: stabil
Einbindung Parser-Funktion
Beschreibung Gets metrics from Google Analytics
Autor(en) Ike Hecht (TosfosDiskussion)
Betreuer WikiTeq team
Letzte Version 1.0.2 (Januar 2023)
Kompatibilitätspolitik Für jede MediaWiki-Version, die ein Long Term Support Release ist, existiert ein entsprechender Zweig in der Erweiterung.
MediaWiki 1.35, 1.39
Datenbankänderungen Nein
Composer mediawiki/google-analytics-metrics
Lizenz GNU General Public License 2.0 oder neuer
Herunterladen
  • $wgGoogleAnalyticsMetricsViewId
  • $wgGoogleAnalyticsMetricsExpiry
  • $wgGoogleAnalyticsMetricsAllowed
Quarterly downloads 5 (Ranked 139th)
Übersetze die GoogleAnalyticsMetrics-Erweiterung, wenn sie auf translatewiki.net verfügbar ist
Probleme Offene Aufgaben · Einen Fehler melden

The GoogleAnalyticsMetrics extension gets various metrics from Google Analytics and inserts them into a wiki page using a parser function. This extension was created for 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.

Installation

  • 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
  • Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens GoogleAnalyticsMetrics im Ordner extensions/ ablegen.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleAnalyticsMetrics
  • Wird von git aus installiert, ist Composer auszuführen, um PHP-Abhängigkeiten zu installieren, indem composer install --no-dev im Erweiterungsverzeichnis ausgeführt wird. (Siehe task T173141 für mögliche Komplikationen.)
  • Folgenden Code am Ende deiner LocalSettings.php -Datei einfügen:
    wfLoadExtension( 'GoogleAnalyticsMetrics' );
    
  •   Erledigt – Zu Special:Version in dem Wiki (bei Einstellung auf deutsch nach Spezial:Version) navigieren, um die erfolgreiche Installierung der Erweiterung zu überprüfen.

Verwendung

The googleanalyticsmetrics parser function takes three parameters, in the form of:

{{#googleanalyticsmetrics: metric=Name der Metrik|page=Seitenname|startDate=Startdatum|endDate=Enddatum}}
Name der Metrik
The name of the Google Analytics Metric that should be displayed. The full list of Google Analytics metrics is here. Omit the ga: prefix.
Seitenname
The name of the page. This parameter is only used when the metric is a per page metric.
Startdatum
Show the metric since this date (optional). Defaults to 2005-01-01, which is the beginning of time according to Google Analytics.
Enddatum
Show the metric until this date (optional). Defaults to today.

Beide Datumsparameter verwenden die Form: Jahr-Monat-Tag.

Beispiele

This example displays the number of page views for this site, from the beginning until the end of time:

{{#googleanalyticsmetrics: metric=pageviews}}

Show the number of sessions from February 3, 2011 until today.

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

Show the average session duration until February 1 2012:

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

Show the number of page views for last month only, with the help of the ParserFunctions extension:

{{#googleanalyticsmetrics: metric=pageviews|startDate={{#time:Y-m-d|Erster Tag letzten Monats}}|endDate={{#time:Y-m-d|Erster Tag dieses Monats}}}}

Or, to make that nicer:

{{formatnum:{{#googleanalyticsmetrics: metric=pageviews|startDate={{#time:Y-m-d|Erster Tag letzten Monats}}|endDate={{#time:Y-m-d|Erster Tag dieses Monats}}}}}}

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.

Konfigurationsparameter

$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.

Siehe auch