Like the other FAQ pages i have thought of adding one for mediawiki also, hope it helps.

Q.How to integrate Google Analytics in MediaWiki?

A.Method1

Go to your MediaWiki main folder and navigate to includes folder and open outputPage.php. Find headElement function and add your google analytics tracking script just before $closeHead = Html::closeElement( ‘head’ ),

$ret .= "<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){";
$ret .="  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),";
$ret .="  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)";
$ret .="  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');";
$ret .="  ga('create', 'UA-CODEFORYOURSITE-1', 'WEBSITEADDRESS');";
$ret .="  ga('send', 'pageview');</script>";
$closeHead = Html::closeElement( 'head' );

Method2
Another way is to edit your Skin file, go to Skins folder, open the corresponding skinname.php like Vector.php, Monobook.php, ..etc. Find function initPage( OutputPage $out ) and add your google snippet as shown below at end of this function,

$out->addScript('<script>google analytics snippet here</script>');

Method3
Use Google Analytics Extension for media wiki. Click here to visit MediaWiki site for analytics Extension.

Q.How to upgrade MediaWiki to latest version from older version?

A.I have shared few steps in another article which will help to upgrade MediaWiki from a primitive version to latest version, see here.

Also MediaWiki have got a great article for upgrading, click here.
Q.How to add your custom side bar for mediawiki?

A.Navigate to your mediawiki folder and to Skins folder. Open your skinfile.php(my case it is vector.php) search for

function renderPortals( $portals )

. Now add your code as below inside this function,

protected function renderPortals( $portals ) {
if ( !isset( $portals['SEARCH'] ) ) {
------Code------
//Custom Side Bar
$portals['CUSTOMSIDEBAR'] = true;
foreach ( $portals as $name => $content ) {
------Code------
switch( $name ) {
------Code------
case 'CUSTOMSIDEBAR':
$this->renderPortal( 'Custom Side Bar', 'Custom side bar contents will be displayed here.', 'custombox', 'SkinTemplateToolboxEnd' );
break;
------Code------

Don’t alter any existing codes. Now after saving your skin file, you will find your custom side bar.

Q.

How to display Google Ads in mediawiki sidebar?

A.Go to your mediawiki folder and navigate to Skins folder. Open your skinfile.php(vector.php,monbook.php,..etc) search for

function renderPortals( $portals )

. Now add your code as below inside this function,

protected function renderPortals( $portals ) {
if ( !isset( $portals['SEARCH'] ) ) {
------Code------
//Custom Side Bar
$portals['ADBOX'] = true;
foreach ( $portals as $name => $content ) {
------Code------
switch( $name ) {
------Code------
case 'ADBOX':
$adboxcontent='<script type="text/javascript">// <![CDATA[';
$adboxcontent.='<!--google_ad_client = "ca-pub-9301220330628396";';
$adboxcontent.='/* toolbarads-mw */';
$adboxcontent.=' google_ad_slot = "4501818787";';
$adboxcontent.=' google_ad_width = 120;';
$adboxcontent.=' google_ad_height = 600;';
$adboxcontent.='// ]]></script>'; 
$adboxcontent.='<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// <![CDATA[';
$adboxcontent.='// ]]></script>';

Don’t alter any existing codes. Now after saving your skin file, you will find your custom side bar.

Be Sociable, Share!