Tillägg:GoogleAnalyticsMetrics

This page is a translated version of the page Extension:GoogleAnalyticsMetrics and the translation is 63% complete.
Other languages:
English • ‎Türkçe • ‎svenska • ‎العربية • ‎日本語
Manual för MediaWikitillägg
OOjs UI icon advanced.svg
GoogleAnalyticsMetrics
Utgivningsstatus: stabil
Genomförande Parserfunktion
Beskrivning Gets metrics from Google Analytics
Författare Ike Hecht (Tosfosdiskussion)
Ansvarig(a) WikiTeq team
Senaste versionen 1.0.0 (april 2018)
MediaWiki 1.25+
PHP 5.3+
MediaWiki 1.36 Not formally tested
MediaWiki 1.34 Not formally tested
MediaWiki 1.32 Not formally tested
Förändringar i databasen Ja
Licenser GNU General Public License 2.0 eller senare
Ladda ner
  • $wgGoogleAnalyticsMetricsViewId
  • $wgGoogleAnalyticsMetricsExpiry
  • $wgGoogleAnalyticsMetricsAllowed
Översätt tillägget GoogleAnalyticsMetrics om det finns tillgängligt på translatewiki.net

Kontrollera användning och versionsmatris.

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
  • Ladda ner och placera filen/filerna i en katalog som heter GoogleAnalyticsMetrics i din extensions/-mapp.
  • Kör bara Composer när du installerar från Git för att installera PHP-beroenden, genom att använda composer install --no-dev i tilläggets katalog. (Se ärende T173141 för tänkbara besvär.)
  • Lägg till följande kod längst ner i dina LocalSettings.php:
    wfLoadExtension( 'GoogleAnalyticsMetrics' );
    
  • Kör uppdateringsskriptetsom automatiskt kommer skapa de nödvändiga databastabellerna som tillägget behöver.
  •   Klart – Ta dig till Special:Version på din wiki för att bekräfta att tillägget har installerats ordentligt.

Användning

Parserfunktionen googleanalyticsmetrics tar tre parametrar, i form av {{#googleanalyticsmetrics: metric=Metrikens namn|page=Sidnamn|startDate=Startdatum|endDate=Slutdatum}}:

Metrikens namn
The name of the Google Analytics Metric that should be displayed. The full list of Google Analytics metrics is here. Omit the ga: prefix.
Sidnamn
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.
Slutdatum
Show the metric until this date (optional). Defaults to today.

Båda parametrarna använder formatet: År-Månad-Dag.

Exempel

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|first day of last month}}|endDate={{#time:Y-m-d|first day of this month}}}}

Or, to make that nicer:

{{formatnum:{{#googleanalyticsmetrics: metric=pageviews|startDate={{#time:Y-m-d|first day of last month}}|endDate={{#time:Y-m-d|first day of this month}}}}}}

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.

Konfigurationsparametrar

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

Se även

  This extension is professionally maintained by the WikiTeq team.