How to track Mobile Website Using Google Analytics? Mobile Website, Server Side Code Snippets, and Google Analytics

We can track mobile sites in the same way as other websites. Since we need to make changes to the tracking code in order for it to track mobile sites we need to use different tracking code. To make sure that Google Analytics reports data from for mobile websites, paste the server-side code snippets on each page we need to track. This will result in Google Analytics creating a profile for the mobile website. Google Analytics will now report the same kind of information as in standard Analytics reports. It includes visitor information and traffic sources and we can track users visiting mobile website from both smartphones (like iPhones and Android devices) and WAP devices separately.

It will work in the following server-side snippets environments:

  • PHP 5
  • JSP on Jetty 6
  • Perl 5.10
  • ASP.NET on IIS 6.0

Now, click the advanced tab below where it asks What are you tracking? There should be a radio button option for “A site created for a mobile phone” which when selected will then also give you a choice of server-side languages

To install the code snippet, select “Advanced” from the “Add new profile” setup wizard within Google Analytics, and select the radio button, “A site built for a mobile phone”. PHP, Perl, JSP and ASPX sites all supported. Simply copy the code displayed into every page you want to track and you will have harnessed the awesome power of Google Analytics to track your mobile visits.

Copy this file to your root directory

Download ga.php and save it to the root directory (“/”) of your web server. Make sure that your root directory is configured to execute server-side code.