Select Page

Adding Google Analytics To MediaWiki

Adding Google Analytics To MediaWiki

MediaWiki-logo I search and search on how to add a Google analytics to MediaWiki, seems pretty damn simple as long as you know which templates you are using as default.

The current skins is configured in LocalSettings.php

## Default skin: you can change the default skin. Use the internal symbolic ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': $wgDefaultSkin = 'monobook';

Head to {mediawiki_root}/skins and edit  the right skins, for me it is MonoBook.php

Just add your analytics scripts before the </body>. Now MediaWiki will add the marker in every page

Before

<?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?> <?php $this->html('reporttime') ?> <?php if ( $this->data['debug'] ): ?> <!-- Debug output: <?php $this->text( 'debug' ); ?> --> <?php endif; ?> </body></html>

After

<?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?> <?php $this->html('reporttime') ?> <?php if ( $this->data['debug'] ): ?> <!-- Debug output: <?php $this->text( 'debug' ); ?> --> <?php endif; ?> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost
+ "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-88600-7"); pageTracker._trackPageview(); } catch(err) {}</script>
</body></html>
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments

Categories

0
Would love your thoughts, please comment.x
()
x