Thursday 2 May 2013

Windows Store App - Google Analytics

1. Download the library from http://w8ga.codeplex.com/releases/view/98265
2. Add reference to it from your app
3. Add the project DT.GoogleAnalytics.Metro in your project as in screen shot


4. Add using DT.GoogleAnalytics.Metro; in the required page in ur app
5. Add the following 2 lines to ur App.xaml, give the exact WebPropertyId - This is very important.

6. Follow the steps  from 3 to 8 in https://w8ga.codeplex.com/wikipage?title=Howto  if u wish to add the GA ref in ur App.xaml.cs 
7. if u want google analytics to work in other pages, add the code below : 

var ver = Windows.ApplicationModel.Package.Current.Id.Version;
var appVersion = ver.Major + "." + ver.Minor + "." + ver.Build + "." + ver.Revision;
//appVersion gives you the version of ur app
string pageUrl = "GAME_SS_" + appVersion.ToString() + "_" + CultureInfo.CurrentCulture.Name + "Win8";
AnalyticsHelper.TrackPageView(pageUrl);
You can give whatever string u want in pageUrl which lets u identify the page of ur app and this url will be displayed in the Google Analytics page.


No comments:

Post a Comment