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.

Google Analytics has released an asynchronous version of their tracking code. Listed among the benefits of using the asynchronous tracking code are shorter page load times and more accurate visitor tracking–both good reasons to consider using the asynchronous code.

Implementing the asynchronous code is as easy as implementing the current, synchronous version. If, however, you have made any customizations to your existing tracking code, you will need to migrate those customizations to the asynchronous version. Those interested in migrating GA tracking code customizations should take a look at Google Analytics for Developers and these migration examples.

via Google Analytics Blog

Google Analytics does not track links to external sites, nor does it track non-pageview events such as file downloads. For most sites, these are pretty valuable metrics that should be tracked. Many people deal with this by manually adding onclick code that calls the _trackPageview function to all of their links. At best, this is time consuming, at worst it is error prone and many links get forgotten.

There are several ways to automate this so that the these external and file download links will get tracked by Google Analytics without the need to add code to every link. One way is to use javascript to add the _trackPageview event to all of the links that need it, dynamically, when the page loads. This ensures that all of links on the page get the proper treatment. This is especially important if you are using some form of CMS where some of the links are likely to be in the content, while others are in the templates. Brian Clifton has a javascript on his site that does just that: Updated auto tracking script for file downloads, outbound links and mailto links

In my experience, this method works quite well, and it takes just a few minutes to implement.