Using Google Analytics in your Windows Store app is quite straight forward. There are a number of free libraries that allow you to do this in minutes. I tried out a few of such libraries and settled on one – for me, the best was Google Analytics SDK for Windows 8 and Windows Phone.
Here’s how you can implement this within your Windows 8 or Phone XAML project (for JavaScript solution, for this guide).
1. Create your Google Analytics Account
3. In your app manifest, add the “Internet” capability under the “Capabilities” tab.
4. Install the Google Analytics SDK via Nuget
6. You should change the tracking-id, the appName and appVersion values.
Obviously the tracking-id should be that of the account created in Google Analytics.
<?xml version=”1.0″ encoding=”utf-8″ ?>
<analytics xmlns=”http://googleanalyticssdk.codeplex.com/ns/easytracker”>
<!–Replace placeholder ID with your tracking ID–>
<trackingId>UA-XXXX-Y</trackingId>
<!–Replace placeholder name with your app name–>
<appName>TestApp</appName>
<!–Replace placeholder version with your app version–>
<appVersion>1.0.0.0</appVersion>
</analytics>
7. Add the tracking code to your porject…
// track the page view
GoogleAnalytics.EasyTracker.GetTracker().SendView(“main”);
// track a custom event
GoogleAnalytics.EasyTracker.GetTracker().SendEvent(“test”, “userclick”, null, 0);
Once you build and test your app, you should instantly see statistics being tracked in the “Real-Time” section of your Google Analytics.