Adding Google Analytics to Media Wiki

I am trying to figure out how to add the Google Analytics code block to my wiki. This tracking code needs to go on every page. Their example is as follows:

Copy and paste the code segment into the bottom of your content, immediately before the tag of each page you are planning to track. If you use a common include or template, you can enter it there.

Important: if your pages include a call to urchinTracker(), utmLinker(), utmSetTrans(), or utmLinkPost(), the tracking code must be placed in your page’s code above any of these calls. In these cases the tracking code can be placed anywhere between the opening tag and the JavaScript call.

You’ll need to update the “xxxx-x” in the sample above with your own Google Analytics account number. You can access your personalized tracking code in its entirety by following the instructions in Where can I find my tracking code?

Any help would be greatly appreciated!



Seems to me the best (obvious?) place to put the code indicated is in your template/skin’s footer.

Generally, this is done by opening the appropriate “skin” file (located at path_to_your_wiki_installation/skins/YourSkinName.php) and editing it with a suitable editor to insert the Google provided code as directed.

For example, using the “default” MonoBook skin shipped with MediaWiki, near the end of the MonoBook.php file, you will find:

[code]<?php $this->html('reporttime') ?>

<?php wfRestoreWarnings(); } } ?>[/code] and inseerting the code, as instructed, immediately before the "" tag, the results looking lilke this:

[code]<?php $this->html('reporttime') ?>

<?php wfRestoreWarnings(); } } ?>[/code] (with the "UA-xxxx-x" appropriately modifed for your use).