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 September 4, 2006 2:29 AM

Comments

There's an extension for this:

http://www.mediawiki.org/wiki/Extension:Google_Analytics_Integration

Posted by: Anonymous at December 20, 2009 9:04 PM

Nice Article

Posted by: dczs at December 9, 2008 6:56 PM

Any idea how long before the script "kicks in" and is detected by google analytics main console page?

I am also waiting for this and wondering whether I installed the code properly.

Posted by: Milan at November 2, 2007 5:06 AM

Won't work on non default skin

Posted by: Anonymous at September 23, 2007 10:20 PM

Thanks!

Posted by: Lee at September 5, 2007 10:12 PM

This was very useful. Any idea how long before the script "kicks in" and is detected by google analytics main console page?

Posted by: Hari Jayaram at June 14, 2007 9:05 PM

Great post!!! thanks a lot.

Posted by: morfeus at June 6, 2007 10:02 AM

Thnanks , it was very helpfull

Google Analytics the best !

Posted by: Semion at May 27, 2007 8:08 AM

thanks for guiding people how to integrate google analytics

Posted by: Appka-Khadim at January 10, 2007 8:41 AM

This code doesn't slow down a site at all, because it's the last thing that's done. That's why the tell you to add it right before the end of the site.

Merry New Years!

-Jeff

Posted by: Jeff at January 1, 2007 6:03 AM

Hi,

Thank you for this concise instruction on how to add Google analytics to MediaWiki. I have been considering adding it to the Appropriate Technology wiki, http://www.appropedia.org, but I am concerned about the speed. If you have implemented this in a wiki, how much slow down have you noticed due to the implementation?

Thank you.

BTW Appropedia.org would be a good place for some instructions to go along with your beer brewing photos.

Posted by: Lonny at October 3, 2006 9:59 PM

Post a comment




Remember Me?