Extension:PageViewInfoGA

MediaWiki extensions manual
OOjs UI icon advanced.svg
PageViewInfoGA
Release status: beta
Description Implements PageViewService for GoogleAnalytics
Author(s) Femiwiki Team
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.36+
Database changes Yes
License GNU Affero General Public License 3.0 or later
Download
CHANGELOG
Translate the PageViewInfoGA extension

Check usage and version matrix.

The PageViewInfoGA extension implements PageViewService for Google Analytics.

InstallationEdit

  • Requires PageViewInfo extension.
  • Download and place the file(s) in a directory called PageViewInfoGA in your extensions/ folder.
  • Only when installing from git run Composer to install PHP dependencies, by issuing composer install --no-dev in the extension directory. (See task T173141 for potential complications.)
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'PageViewInfoGA' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Install the global site tagEdit

You need to set $wgPageViewInfoGATrackingID to the ID of the Google Analytics property to which you want to send data to send event data to Google Analytics. (See the document for details)

Create a service account and enable the Analytics APIEdit

You need to create a service account and enable Analytics API to use PageViewInfoGA. See the document for details.

Configure credentialsEdit

You need to set $wgPageViewInfoGACredentialsFile to the path to your service account credentials you have downloaded in the previous step.

Configure profile IdEdit

You need to set $wgPageViewInfoGAProfileId to your profile Id(View ID).

(Optional) Create and Use Custom DimensionsEdit

There is not yet a guide for creating custom dimensions on Google Analytics web interface for this extension. See the document on Google instead.

After creating custom dimensions, set $wgPageViewInfoGAWriteCustomDimensions to valid array.

// Default to:
$wgPageViewInfoGAWriteCustomDimensions = [
    "dimension1" => "mw:page_id",
    "dimension2" => "mw:page_title",
];

Finally, you can use the custom dimensions.

$wgPageViewInfoGAReadCustomDimensions = true;

See alsoEdit


This extension was originally made for Femiwiki.