Lonny's picture

Google analytics and socialmedia links in Mediawiki

So the upgrade of MediaWiki (MW) to 1.11 was successful, thanks to Gabe! I really should blog on the many improvements (such as tags working for image galleries - YES), but instead I am going to mention one of the breaks. Google Analytics (GA) stopped working. This means we now only have AWstats and MediaWiki data for this last week. The reason that it broke is that I placed the GA tracker in the MonoBook.php skin. The MW upgrade replaces that skin. So I put it back in today. This is how:

  • Go onto your server
  • Navigate to your skins directory
  • copy MonoBook.php to MonoBook.WhatEverYourBackUpSchemeIs (for me this was cp MonoBook.php MonoBook.1_08_08)
  • edit MonoBook.php
  • Find, near the very end of the file, the following code: -/body- -/html- (replacing - with < or >)
  • Insert your Google Tracker, for me this looked like:

Adding Google Analytics to MediaWikiAdding Google Analytics to MediaWiki

  • Save and you should be good.
  • To check it, look at your page source after doing a hard reset. You should see the code near the bottom.

Since I was in the skin. I decided to add back some of the social media link that we had, but this time using addthis.com. To do this, go get an addthis.com account, then:

  • Go back into the Monobook.php file
  • Find, near the very end of the file before the Google Analytics, the following code:

-div class="pBody" align="right"-
-div id="footer"-
(replacing - with < or >)

  • Insert the addthis code between these two lines of code, for me it looked like this:

Adding Addthis to MediaWikiAdding Addthis to MediaWiki

Now Google Analytics should be working and you should have some social media links in the lower left of your skin. There is probably a much better place for this. We are working on a all new skin, so I am stopping here for the moment. Good luck.

Reply

The content of this field is kept private and will not be shown publicly.
  • <ref>, </ref> around notes. <nowiki>, </nowiki> around text not to be formatted.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <sup> <h1> <h2> <h3> <h4> <h5> <big> <small> <img> <ref> </ref> <references> <nowiki> </nowiki>
  • Allow MediaWiki syntax (limited).
  • Images can be added to this post.
  • Handle "[[Page]]" (wikis), [http://... link text] (exts)
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You can use context links in the text to create context-related links to pages or sites that provide additional information about a word or phrase.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.