Update 2010-05-12: At some point in the last couple weeks, the option for creating a mobile GATC seems to have disappeared. Mobile tracking, as described below, seems to be working. But, I have heard of others having problems. There doesn’t seem to be any official word from Google on this, yet.

google analytics mobile tracking codeVisits to your site from browsers that do not run javascript will not be tracked by the standard Google Analytics Tracking Code (GATC). This isn’t a huge problem on most sites. On mobile sites, however, this can mean that you are not collecting data on a significant percentage of your visitors.

Google Analytics has the ability to track mobile sites without using javascript. This works by making a server side call to Google Analytics rather than relying on the browser to make this call with javascript. Google has provided example code in PHP, PERL, Java and ASPX. Unfortunately, they do not provide an example rails implementation–not yet anyway. To fill that void, Moneyspyder has created a sample Ruby on Rails application that implements the Google Analytics mobile tracking code (also available on github).

When I implemented mobile tracking on a site, I (very wrongly) used the sites regular “UA” account number. Mobile page views were indeed tracked, but only as one visitor. To say this another way, all mobile visitors activity looked as if they were coming from one single, long visit with a ton of page views. When I used the proper, mobile account number things started looking much better. This is strange behavior, but someone reported the same problem in the GA support forum. So, learn from my mistake.

To get started with Google Analytics mobile tracking, get your mobile Google Analytics account number by creating a new GA profile or hitting the “check status” link on an existing profile’s settings page. Once you are on the page that contains the standard tracking code, click over to the advanced tab and select the “A site built for a mobile phone” radio button. You’ll see some example code (the default is PHP). Your mobile GA account number is listed near the top (“$GA_ACCOUNT = “MO-XXXXXXX-X”;”). It will look pretty much the same as your regular account number with one exception. The first two letters will be “MO” rather than “UA”.

One other caveat here is that you should not attempt to use both the standard GATC and the server side tracking code on the same page.

Leave a Reply

Your email address will not be published. Required fields are marked *