Extension:Google Analytics Integration
From MediaWiki.org
|
Google Analytics Release status: stable |
|
|---|---|
| Implementation | User activity |
| Description | Automatically inserts Google Analytics tracking code at the bottom of MediaWiki pages |
| Author(s) | Tim LaquaTalk |
| Last version | 2.0.2 (2009-12-16) |
| MediaWiki | 1.11+ |
| License | No license specified |
| Download | Download snapshot Subversion [Help] |
| Example | Wikimini (view page source at the bottom) |
|
Check usage (experimental) |
|
This extension inserts Google Analytics tracking code in every MediaWiki page that is viewed. The extension excludes pages being viewed by users with 'protect' privileges (sysops) and users with 'bot' privileges (bots) to prevent pollution of the statistics. To use a version that also ignores logged-in users, see the 'See also' section at the end of this page.
Contents |
[edit] Installation
- Create a new folder (directory) in the following location:
wiki-install-folder/extensions/googleAnalytics - Download the googleAnalytics.php files from SVN
- Copy googleAnalytics.php and googleAnalytics.i18n.php in to the new googleAnalytics folder
- Add the following line to your LocalSettings.php at the bottom:
require_once( "$IP/extensions/googleAnalytics/googleAnalytics.php" );
In the googleAnalytics folder, googleAnalytics.php you can find the following and edit as appropriate:
# Replace xxxxxxx-x with YOUR GoogleAnalytics UA number $wgGoogleAnalyticsAccount = "UA-xxxxxxx-x"; # Optional Variables (both default to true) $wgGoogleAnalyticsIgnoreSysops = false; $wgGoogleAnalyticsIgnoreBots = false; #If you use AdSense as well and have linked your accounts, to enable tracking set this to true $wgGoogleAnalyticsAddASAC = false;
- NOTE: Backwards compatability has been removed - this extension now requires MediaWiki 1.11+
For the last version supporting MW 1.10, see http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/googleAnalytics/?pathrev=29077- To see how to set the old version up, see an old version of this page.
[edit] Usage
- Create a Google Analytics account
- Locate your UA number
- For the legacy code block, it can be found on the following line:
_uacct="UA-xxxxxxx-x";
- For the new ga.js code block, it can be found on the following line:
var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
- For the legacy code block, it can be found on the following line:
- Follow Installation Instructions
- Google Analytics stats should start populating within 24-48 hours.
[edit] Bugs
- With PHP 5.3.2/5.3.3 on MediaWiki 1.16 or after use following fix. Your PHP version can be seen on the Special:Version page.
The error message before this fix is:
- MediaWiki internal error. Exception caught inside exception handler.
- The googleAnalytics.php file will override your variables that were set in the LocalSettings.php file if you include it after you set these variables. It will appear to not work because you'll probably be logged in as a SysOp and it ignores you for the statistics by default. Solution: It should check the variables (isset)
[edit] See also
- Google Analytics - this same extension but also allows you to ignore logged in users (new variable is used, $wgGoogleAnalyticsIgnoreUsers). This is useful since if we want true visitors statistics, we want to ignore logged-in users who are often 'wiki-workers' and perhaps we dont want to include their stats since they could have lots of page views, like sysops.
- User:Dantman/Analytics integration - Techniques on how to flexibly add analytics without using extensions.
- Extension:Open Web Analytics - Similar extension using Open Web Analytics.
| Language: | English • Русский |
|---|
