« August 2006 | Main | October 2006 »

September 4, 2006

Adding Google Analytics To MediaWiki

MediaWiki Logo
In order to add Analytics to MediaWiki, you first need the script code from Google. It should look something like this:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-XXXXX-X";
urchinTracker();
</script>

We need to insert the script code into MediaWiki so that it appears in every page generated. But where? In the MediaWiki's base skin php file. If you haven't changed the skin from the default, then you have the "MonoBook" skin. Edit the following file:

/wiki/skins/MonoBook.php

And insert the Google script code near the end of the file, just above the </body></html> tags. That's it. All pages will now execute the script.

Posted by stoltenow at 2:29 AM | Comments (11)