Category Archives: Google

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

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
...
...
ga('send', 'pageview');

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

Advertisements

Google – impressive and fail

Google is getting more impressive (and scary) all the time. Today a friend sent me an email where he asked me whether I have any idea what the items in the attached photos might be. Google’s Inbox figured out what the email was about and suggested three possible answers, see photo.

IMG_0636

On the other hand Google also comes up with quite strange results. Look at the definition I got when I searched for Garnet.

google fail.png

Installing the Google Data Python Library on a Raspberry Pi

Google doesn’t mention this in their Getting Started article for the Google Data Python Library, I guess there are just too many operating systems and distributions, but the Google Data Python library is available as a Debian package called python-gdata.

You can install it in Raspbian using

sudo apt-get install python-gdata

If you are using Google’s 2-step verification and want to access your account using  the Google Data Python Library you will have to generate an application-specific password if you want to use the ClientLogin authentication. There are also other authentication methods, but I have not tried them yet. ClientLogin only seems to work with the deprecated API v1, but the later APIs seem to need a lot more imports.