This project has moved and is read-only. For the latest updates, please go here.

Getting Started

If you have not already done so, create a Google Analytics account. Be sure to choose "App" instead of "Web Site" when creating your account.
Note: only newer Google Analytics properties created after March 2013 will work with this SDK.

Once you have an account and tracking ID you are ready to start using the SDK.

There are four steps to getting started with the SDK:
  1. Update your application manifest
  2. Install the NuGet package
  3. Modify your analytics.xml file
  4. Add EasyTracker methods

After completing these steps, you'll be able to measure the following with Google Analytics:
  • App installations
  • Active users and demographics
  • Screens and user engagement
  • Crashes and exceptions

1. Update your application manifest

The only capability you need to add to your application is the IDCAPNETWORKING capability for Windows Phone or Internet (Client) capability for Windows 8 store apps. These capabilities are already selected by default but you should confirm to make sure your app can send data over the internet.

On Windows Phone (7 & 8):


On Windows 8 store apps (JavaScript and Xaml):


2. Install the NuGet package

Option A: From Visual Studio Nuget Package Manager

  1. Right click on your project and choose 'Manage NuGet Packages'
  2. Search for "GoogleAnalyticsSDK"
  3. Click 'Install'.

Option B: Run the following command in the Package Manager Console

PM> Install-Package GoogleAnalyticsSDK -Pre

3. Modify your analytics.xml file

By default, a file called analytics.xml will be automatically added to the root of your project. This file contains configuration options that you must edit. At the very least, you should always modify your tracking ID, app name and version:
<?xml version="1.0" encoding="utf-8" ?>
<analytics xmlns="">
  <!--Replace placeholder ID with your tracking ID-->
  <!--Replace placeholder name with your app name-->
  <!--Replace placeholder version with your app version-->
See the analytics.xml parameters reference for the complete list of parameters you can use to configure your implementation.

4. Add EasyTracker methods

Add a single line of code to your app for each event you want to track. Here are examples of the different types of activities you can track in your app:
// track a page view
// track a custom event
GoogleAnalytics.EasyTracker.GetTracker().SendEvent("test", "userclick", null, 0);
// manually track an exception
GoogleAnalytics.EasyTracker.GetTracker().SendException("oops, something went wrong", false);
// track a transaction (in app purchase)
double cost = 1.99;
long costInMicrons = (long)(cost * 1000000);
var transaction = new GoogleAnalytics.Transaction("01234", costInMicrons);
var item = new GoogleAnalytics.TransactionItem("myproduct", "My Product", costInMicrons, 1);
// track a social networking interaction
GoogleAnalytics.EasyTracker.GetTracker().SendSocial("facebook", "share", "");
// track a timing (how long it takes your app to run a specific task)
GoogleAnalytics.EasyTracker.GetTracker().SendTiming(DateTime.Now.Subtract(startTime), "Startup", "MainPage", "Label");

JavaScript Windows Store Apps

The same APIs are available for JavaScript, C#, VB.NET, & C++ and work the same for both Windows 8 store apps and Windows Phone 7.1 and 8 applications.
JavaScript developers should note that WinRT objects are exposed to JavaScript with some minor casing changes that are more consistent with JavaScript naming conventions. Therefore to track a page in JavaScript you would need to do something like the following (note the case change on properties and methods):
// track a page view
Warning: The Google Analytics SDK for Windows 8 and Windows Phone can automatically track exceptions and application lifetime events if autoAppLifetimeTracking is set to true in analytics.xml. However, this is not supported in JavaScript store applications. WinRT objects cannot gain access to JavaScript store application lifetime events such as suspend, resume, and unhandled exceptions like they can for Xaml based apps. Therefore, if using JavaScript you should consider manually calling EasyTracker for these events.

Congratulations! Your app is now setup to send data to Google Analytics.

Last edited Aug 12, 2013 at 12:58 AM by timgreenfield, version 10