This document discusses setting up and using Google Analytics and the Microsoft Silverlight Analytics Framework (MSAF) for tracking usage data in Windows Phone apps. It covers creating Google Analytics accounts and properties, configuring MSAF in an app, and tracking common events like pageviews and custom events. Useful tracking options are also outlined, like tracking app versions, reviews/sharing, and monetization events. Links to relevant resources are provided.
7. Google Analytics – Accounts
• You can only start 20 accounts
• Given access to unlimited accounts
8. Google Analytics – Web
Properties
• An account can have only 50 properties
• Web Property = tracking code
9. Google Analytics – Profiles
and Filters
• Limited to 50 profiles (over all properties)
• Filters incoming data
• Filters executed in order of definition
• Always keep a profile with all raw data
10. Google Analytics – Advanced
Segments
• Isolate and analyse your analytics data
• Default or Custom Advanced Segments
11. Google Analytics – Dashboards
• Sticky to login
• Configuration sharing
• Widgets added via filters
• Export and Email
16. MSAF
• Web analytics Framework
• Supports
– Silverlight, WPF and Windows Phone
– Offline scenarios
– Pageview and event tracking
– …
• Extensible
• Get it from http://msaf.codeplex.com/
19. Adding it to your application
• Add the code to your App.xaml
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
<Analytics:AnalyticsService x:Name="analyticsService" WebPropertyId="UA-12345678-9"
AutomaticPageTrackingEnabled="True" />
</Application.ApplicationLifetimeObjects>
20. Adding it to your application
• And to App.xaml.cs
<pre class="brush: csharp;">
public partial class App : Application
{
private AnalyticsTracker _tracker;
public AnalyticsTracker Tracker
{
get
{
if (_tracker == null)
{
AnalyticsService service = null;
foreach (var obj in this.ApplicationLifetimeObjects)
{
if (typeof(AnalyticsService).Equals(obj.GetType()))
{
service = obj as AnalyticsService;
break;
}
}
_tracker = new AnalyticsTracker(service);
}
return _tracker;
}
}
}
21. Application properties
• Google Analytics: 5 custom variables
public class AnalyticsService : IApplicationService
{ Key 1: ProductID
private readonly IApplicationService _innerService;
private readonly GoogleAnalytics _googleAnalytics;
public AnalyticsService() Key 2: User defined
{
_googleAnalytics = new GoogleAnalytics();
_googleAnalytics.CustomVariables.Add(
new PropertyValue
{
Key 3: User defined
PropertyName = "Device ID",
Value = AnalyticsProperties.DeviceId
});
... Key 4: User defined
}
}
Key 5: User defined
22. Reading the manifest
public class PhoneHelper
{
const string AppManifestName = "WMAppManifest.xml";
const string AppNodeName = "App";
public static string GetAppAttribute(string attributeName)
{
try
{
var settings = new XmlReaderSettings { XmlResolver = new XmlXapResolver() };
using (var rdr = XmlReader.Create(AppManifestName, settings))
{
rdr.ReadToDescendant(AppNodeName);
if (!rdr.IsStartElement())
{
throw new FormatException(AppManifestName + " is missing " + AppNodeName);
}
return rdr.GetAttribute(attributeName);
}
}
catch (Exception)
{
return "";
}
}
}
23. Pageview Tracking
public class AnalyticsService : IApplicationService
{
private readonly IApplicationService _innerService;
private readonly GoogleAnalytics _googleAnalytics;
public AnalyticsService()
{
_googleAnalytics = new GoogleAnalytics();
_googleAnalytics.CustomVariables.Add(
new PropertyValue
{
PropertyName = "Device ID",
Value = AnalyticsProperties.DeviceId
});
...
_innerService = new WebAnalyticsService
{
IsPageTrackingEnabled = true,
Services = { _googleAnalytics, }
};
}
}
24. Pageview Tracking
• Basic tracking
– For apps with many pages
– Shows in analytics as pagename.xaml?p1=v1
• Realtime analytics
25. Event Tracking
public class AnalyticsTracker
{
private AnalyticsService _service;
public AnalyticsTracker(AnalyticsService service)
{
CompositionInitializer.SatisfyImports(this);
_service = service;
}
[Import("Log")]
public Action<AnalyticsEvent> Log { get; set; }
public void Track(string category, string name, string actionValue)
{
Log(new AnalyticsEvent
{
Category = category,
Name = name,
ObjectName = actionValue
});
}
}
26. Event Tracking
used for pageviews
public void TrackPageView(string pageViewName)
{
// Avoid double tracking
if (_service != null && !_service.AutomaticPageTrackingEnabled)
{
Log(new AnalyticsEvent
{
ActionValue = pageViewName,
HitType = Microsoft.WebAnalytics.Data.HitType.PageView,
Name = "CurrentScreenChanged",
NavigationState = pageViewName,
ObjectType = pageViewName,
AppName = Analytics.AnalyticsProperties.ApplicationTitle
});
}
}
}
32. Useful trackings
• Application events
– Game modes
• Game controls
• Levels played / Difficulty
– Use of Hints, Tips, …
– Advertising
• Providers
• Number of ads displayed, clicked
– …
Independent consultant, mainly .NET, functional analystLong term experience in mobileWhat am I not:No google analytics expert or certificationLearned from experience and tracking windows phone applications in the last 6 months
Before we start: who are you?Who has already used google analytics?Who has already used filters?Who has already used advanced segments?Who has already used google analytics for silverlight / windows phone?Why google analytics: because I wanted the data as raw as possible?
Used when data is collected:AccountsWeb propertiesProfilesFiltersUsed / Customizable anytimeAdvances segmentsDashboards
Start max 20 accounts, but given access to unlimited client should start the accountNo more than one account / clientElse clients have access to each other dataShow account list in gaShow how to set up an account
NOT POSSIBLE to change property from one account to anotherWeb property = tracking codeShow how to create a property
Profile is a filtered web propertyMultiple filters can be appliedData that is not in the filter cannot be usedShow how to create profiles / filters
More flexible than filters.Can be changed at runtime Not always 100% correct as not all data is usedShow how to create advanced sements
More flexible than filters. Can be changed at runtimeConfiguration sharing happens at time of sharing, updates of configuration are not automatically sharedExport and email is PDF onlyShow how to create dashboards
More flexible than filters. Can be changed at runtimeConfiguration sharing happens at time of sharing, updates of configuration are not automatically sharedExport and email is PDF only
Filter on page title: Only when pages are tracked manually and page title is application name
Only when pages are tracked manually and page title is application nameShow real time analytics
Support for many analytics services
- Any information of the phone or user can be used as a custom variable- But remember filters do not work on custom variables
Any information of the phone or user can be used as a custom variableOther custom variables are generally read from the manifest fileXml parserCopied from coding4fun libraryUse complete library if you use other features
Any information of the phone or user can be used as a custom variable
You can track more than pageviewsEvent tracking is most useful for apps as they tell what the user does
Any information of the phone or user can be used as a custom variable
Microsoft does not provide version informationTracking from Microsoft is a couple of days behind