Extension:Google Analytics Links

This extension provides a Wiki solution for the two questions posted here and here. Use Extension Talk:Google_Analytics_Links for feedback

Syntax
" " " "

Requirements
For this extension to function, it requires that another extension be installed first: Google Analytics. Note: If you already have this extension installed, you must uninstall it first!

Note: I had trouble with that extension throwing an exception when executing the line: if (!$wgUser->isSysop) { I'm not sure why, so I changed it to: if ($wgUser->getName != "Dave") { (Since my login name is "Dave" on my wiki, you should change this line to your name or your wiki admin's name)

Code
<?php /*	Google Analytics Links - v1.0 (c)2007 Nik Molnar (nik.molnar@gmail.com) Distributed UNDER THE TERMS OF GNU GPL Licence. This extension allows you to easily make use of Google Analytics to track non-HTML files (PDF, AVI, etc.) via JavaScript. For more information: http://www.google.com/support/analytics/bin/answer.py?answer=27242 Requires: prior installation of: http://iguane39.free.fr/mediawiki/index.php?title=MediawikiEtGoogleAnalytics/En which sets up the proper account info and scripts Usage: http://yoursite.com/therealfile.pdf|Link Name|/google/friendly/path Output: Link Name

$wgExtensionFunctions[] = "wfGAnalyticsExtension";

//Register the hook function wfGAnalyticsExtension { global $wgParser; $wgParser->setHook("googa", "renderGAnalytics"); }

//Render function function renderGAnalytics($input) { //Pase the arguments $args = split("[|]", $input); //Return the rendered output return "". $args[1]. ""; }

?>

Installation
//Google Analytics Links Extension http://www.mediawiki.org/wiki/Extension:Google_Analytics_Links include_once("extensions/googa.php");
 * 1) copy the above code to a new text file called "googa.php"
 * 2) place that file in your /wiki/extensions/ folder
 * 3) edit your /wiki/LocalSettings.php file
 * 4) After the existing line: $googleAnalytics = "UA-xxxxxxx-1"; insert this line:

Examples
See examples of this extension in action at these fine wikis: kJams

Related extensions
Google Analytics