Dabr & the three A’s

Google Analytics is one of those great Google products that I’ve used from the start. It provides very useful statistics, graphs and alerts about site usage. I use it for all of my sites and have recently modified Dabr to work with it too – with only a handful of minor obstacles along the way.

First up was the fact that Google Analytics historically never had very good mobile support. Even once that was in place, I had to mess about with Google’s PHP code to add support for Opera Mini’s proxy servers.

Then, once I had the tracking code in place and was starting to get some nice stats – I noticed a piece of text that I should have seen before I started anything:

5M pageview cap per month for non AdWords advertisers.

Whoops – Dabr has a lot more pageviews than that!

AdWords is their service where you pay Google to show adverts that point to your site. Of course I’ve had to sign up to this (at an initial setup cost of £10) and there should begin to be a few Dabr adverts appearing on websites around the web. I’ve even started getting a few clicks.

Google charges me with every click of those adverts, which is a little annoying, so I’ve set up AdSense too.

AdSense is the opposite of AdWords. It’s where I get to add other people’s adverts to my sites and I get a trickle of cash for doing so. Typically I’ve seen clicks earning me about 10p to £1 each, but clicks are fairly rare. I don’t (yet) know enough about CPM and those kind of fancy buzzwords to tell you any real figures. I’m sure I’ll blog something in the new year.

So now I’ve got the three A’s working nicely for Dabr:

  • AdWords to bring in potential new users,
  • AdSense to bring in a little cash,
  • and Analytics to track site usage.

Thanks Google :)

5M pageview cap per month for non AdWords advertisers.

AdSense and Multiple Analytics accounts

I have one AdSense account (the forced limit) and three Analytics accounts (work, personal, and Dabr). Can I link them up how I want to? No.

The AdSense account is used to show ads down the side of this site, which I thought was an interesting idea to see what kind of money it can pull in. It’s not much, about £1.67 in 40 days. It has highlighted something annoying to me though.

Google lets you link up your Analytics account to your AdSense account so you can get some fairly interesting statistics like those shown in the screenshot on the right. I like it a lot as I’m a big fan of Analytics and what it can do. Unfortunately, they’ve made the next part a little frustrating: you can only link one of your Analytics accounts to AdSense (remember I have three).

So what if I want to show AdSense stats on another account? I can’t. You’re not even allowed to set up a second AdSense account because the sign up form specifically tells you not to (and makes you tick a box to agree to that). To add even more frustration, unlinking your Analytics and AdSense accounts is a manual process and you need to visit Google’s How do I unlink my AdSense account from Google Analytics? page to contact their team to do it for you.

All that for some stats? Thankfully my other experience with both products has been rather smooth – for now at least! In a few days the Dabr account will go over the 5M pageviews/month limit for free accounts and I may need to sign up to AdWords to keep that working. Fun fun.

Google Mobile Analytics and Opera Mini

Google Analytics is a popular web statistics site with lots of useful features, I’ve been a big fan since the start. Google recently added a bunch of new features, and an important one out of those for me is mobile web tracking.

Typically, Google’s way of tracking site usage is to ask you to put a small snippet of HTML onto your site which is essentially a javascript call to their servers. Great – except a lot of mobile phones don’t actually support javascript. So the only good solution is to run some code on the server. I don’t know if it’s related to Google’s purchase of AdMob, but they’ve done exactly that and provided server side code in various programming languages (C#, PHP, etc) to achieve this. See ga.php as a real example.

Great, now I’ve got beautiful graphs showing me how people use my site. But what’s that? 25% of my users live in the country (not set)? I’ve not heard of the place! It turns out those users more or less all used one browser: Opera Mini.

Oh Opera Mini, what a strange beast you are. While the Opera browser is a full normal browser, Opera Mini is a service that installs a thin client on your phone and Norwegian proxy servers visit the site for you. Norway? Well that’s a little better than living in (not set).

Luckily, this whole problem is fixed by a teensy change in their server side code. Rather than always fetching the browser’s current IP address, I tweaked Google’s PHP code so that it detects Opera Mini is in use and sends the real user’s IP address. To be honest, I’m a little confused why this isn’t in Google’s code in the first place.

So here it is. A minor fix to Google’s ga.php file (line 162) to improve Opera Mini handling:

Original line: "&utmip=" . getIP($_SERVER["REMOTE_ADDR"]);

and my version: "&utmip=" . getIP((stristr($_SERVER['HTTP_USER_AGENT'], 'opera mini') && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) ? $_SERVER['HTTP_X_FORWARDED_FOR']: $_SERVER["REMOTE_ADDR"]);

That’s all. Now I get real country stats :)