<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Carrington &#187; Opera Mini</title>
	<atom:link href="http://davidcarrington.co.uk/tag/opera-mini/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidcarrington.co.uk</link>
	<description>UK web developer that loves phones</description>
	<lastBuildDate>Wed, 25 Jan 2012 13:53:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Google Mobile Analytics and Opera Mini</title>
		<link>http://davidcarrington.co.uk/2009/12/google-mobile-analytics-and-opera-mini/</link>
		<comments>http://davidcarrington.co.uk/2009/12/google-mobile-analytics-and-opera-mini/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 22:36:12 +0000</pubDate>
		<dc:creator>David Carrington</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Opera Mini]]></category>

		<guid isPermaLink="false">http://davidcarrington.co.uk/?p=175</guid>
		<description><![CDATA[Google Analytics is a popular web statistics site with lots of useful features, I&#8217;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&#8217;s way of tracking site usage is to ask you to put [...]]]></description>
			<content:encoded><![CDATA[<p>Google Analytics is a popular web statistics site with lots of useful features, I&#8217;ve been a big fan since the start. Google <a href="http://analytics.blogspot.com/2009/12/holiday-bonus-more-great-features.html">recently added</a> a bunch of new features, and an important one out of those for me is <em>mobile web tracking</em>.</p>
<p>Typically, Google&#8217;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 &#8211; except a lot of mobile phones don&#8217;t actually support javascript. So the only good solution is to run some code on the server. I don&#8217;t know if it&#8217;s related to <a href="http://googleblog.blogspot.com/2009/11/investing-in-mobile-future-with-admob.html">Google&#8217;s purchase of AdMob</a>, but they&#8217;ve done exactly that and provided server side code in various programming languages (C#, PHP, etc) to achieve this. See <a href="https://ssl.gstatic.com/analytics/20091201/mobile/ga.php">ga.php</a> as a real example.</p>
<p>Great, now I&#8217;ve got beautiful graphs showing me how people use my site. But what&#8217;s that? 25% of my users live in the country <em>(not set)</em>? I&#8217;ve not heard of the place! It turns out those users more or less all used one browser: Opera Mini.</p>
<p><a href="http://www.flickr.com/photos/thox/4172396551/"><img class="alignright" title="Photo of Opera Mini looking at dabr.co.uk" src="http://farm3.static.flickr.com/2644/4172396551_09fa706773_m.jpg" alt="" width="180" height="240" /></a>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&#8217;s a little better than living in <em>(not set)</em>.</p>
<p>Luckily, this whole problem is fixed by a teensy change in their server side code. Rather than always fetching the browser&#8217;s current IP address, I tweaked Google&#8217;s PHP code so that it detects Opera Mini is in use and sends the real user&#8217;s IP address. To be honest, I&#8217;m a little confused why this isn&#8217;t in Google&#8217;s code in the first place.</p>
<p>So here it is. A minor fix to Google&#8217;s ga.php file (line 162) to improve Opera Mini handling:</p>
<p>Original line: <code>"&amp;utmip=" . getIP($_SERVER["REMOTE_ADDR"]);</code></p>
<p>and my version: <code> "&amp;utmip=" . getIP((stristr($_SERVER['HTTP_USER_AGENT'], 'opera mini') &amp;&amp; array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) ? $_SERVER['HTTP_X_FORWARDED_FOR']: $_SERVER["REMOTE_ADDR"]);</code></p>
<p>That&#8217;s all. Now I get real country stats :)</p>
]]></content:encoded>
			<wfw:commentRss>http://davidcarrington.co.uk/2009/12/google-mobile-analytics-and-opera-mini/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

