Extension:GoogleAnalyticsMetrics

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

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


 * Name of metric
 * The name of the Google Analytics Metric that should be displayed. The full list of Google Analytics metrics is here. Omit the  prefix.


 * Page Name
 * The name of the page. This parameter is only used when the metric is a per page metric.


 * Start date
 * Show the metric since this date (optional). Defaults to, which is the beginning of time according to Google Analytics.


 * End date
 * Show the metric until this date (optional). Defaults to.

Both date parameters use the form: Year-Month-Day.

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

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

Show the average session duration until February 1 2012:

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

Or, to make that nicer:

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

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

There is also a  function but it only works if the   js library has already been loaded.

Configuration parameters

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