Google Analytics für WP7 Apps
Ich habe einen coolen Post mal wieder gefunden, über den Einsatz von Google Analytics und dem Silverlight Analytics Framework .
Abb.: Analyse von App Nutzungen
Mit etwas Aufwand ist dieses Framework schnell in die eigene App eingebaut. Nach dem Download der Tools müssen als erstes die Referenzen gesetzt werden.
- Microsoft.WebAnalytics.dll
- Microsoft.WebAnalytics.Behaviors.dll
- System.ComponentModel.Composition.dll
- System.ComponentModel.Composition.Initialization.dll
- System.Windows.Interactivity.dll
Also nächtes sollte dich der Developer einen Google Analytics Account anlegen und einen sogenannten WebPropertyId von Google besorgen. Danach noch die einige Zeilen Code und das Tool ist fertig eingebaut.
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 });
_googleAnalytics.CustomVariables.Add(
new
PropertyValue { PropertyName =
"Application Version"
, Value = AnalyticsProperties.ApplicationVersion });
_googleAnalytics.CustomVariables.Add(
new
PropertyValue { PropertyName =
"Device OS"
, Value = AnalyticsProperties.OsVersion });
_googleAnalytics.CustomVariables.Add(
new
PropertyValue { PropertyName =
"Device"
, Value = AnalyticsProperties.Device });
_innerService =
new
WebAnalyticsService
{
IsPageTrackingEnabled =
false
,
Services = { _googleAnalytics, }
};
}
public
string
WebPropertyId
{
get
{
return
_googleAnalytics.WebPropertyId; }
set
{ _googleAnalytics.WebPropertyId = value; }
}
#region IApplicationService Members
public
void
StartService(ApplicationServiceContext context)
{
CompositionHost.Initialize(
new
AssemblyCatalog(
Application.Current.GetType().Assembly),
new
AssemblyCatalog(
typeof
(AnalyticsEvent).Assembly),
new
AssemblyCatalog(
typeof
(TrackAction).Assembly));
_innerService.StartService(context);
}
public
void
StopService()
{
_innerService.StopService();
}
#endregion
}
Also Beispiel Tracker wird unter Einsatz von MEF, dieser wie folgt implementiert:
public
class
AnalyticsTracker
{
public
AnalyticsTracker()
{
CompositionInitializer.SatisfyImports(
this
);
}
[Import(
"Log"
)]
public
Action<AnalyticsEvent> Log {
get
;
set
; }
public
void
Track(
string
category,
string
name)
{
Track(category, name,
null
);
}
public
void
Track(
string
category,
string
name,
string
actionValue)
{
Log(
new
AnalyticsEvent { Category = category, Name = name, ObjectName = actionValue });
}
}
Diese Analyse sollte man als App Entwickler unbedingt nutzen um die App noch zu verbessern und welche Funktionen den meisten Traffic haben.
Quelle:
Advertisements