Tag Archives: Analytics

Using Google Analytics with MediaWiki

After upgrading a Wiki to MediaWiki 1.28 I noticed that in AdSense the page views immediately dropped to 20% of the pre-upgrade values.

I am not sure why that is. I have four Hypotheses:

  1. AdSense doesn’t get displayed for all visitors anymore, even though it seems to display fine when I tried it on different desktop and mobile browsers.
  2. After the upgrade ad blockers block the ad for many visitors (but that shouldn’t cause a drop to 20% or the old numbers).
  3. The web gets cached now, so not every page view causes a new ad to be displayed
  4. The upgrade caused the wiki to feature less prominently on Google, so fewer visitors are coming (unlikely as I don’t think the effect would have been that immediate)

There could, of course, be many other reasonsindex.php?title=MediaWiki:Common.js, but everything else I came up with seems even less likely than hypothesis 2 or 4.

Installing Google Analytics

My plan now is to install Google Analytics again to give me a better idea of what is going on, i.e. to see whether the page view numbers in Google Analytics match the ones from Google AdSense.

I did have Google Analytics installed in this wiki about ten years ago, but I took it off again. Of course, I don’t remember at all how I did it, so I thought this time I write down what I did.

I took the tracking code found in Google Analytics at

Admin / Property / Tracking Info / Tracking Code

..it looks like this

ga('send', 'pageview');

and added it to MediaWiki:Common.js, accessible through the wiki itself, e.g. (index.php?title=MediaWiki:Common.js).