|
||||
|
Silverlight Analytics Tracking Flexibility While not illustrated by the examples in this article, it would also be possible to collect tracking data for use by multiple analytics services. Of course, in a case like that the effect on application performance should be carefully evaluated. Silverlight Analytics—CodePlex Although Google Analytics Event Tracking was introduced in October 2007, it is still in beta. The help files for Google Analytics include an explanation of Event Tracking without mentioning that it has not yet been released. The following discussion therefore assumes that eventually it will be released and that for those who are less patient, it may be possible to enroll in the beta program. Until actual release, however, unless you are participating in the beta program, even though you have the appropriate event tracking code in your web pages and Silverlight application, the reports from Google Analytics will not include any event tracking information. GA Event Tracking can provide data both on events and sub-categories of events. Picture this as being similar to grouping subtotals in a spreadsheet. For example, assume that your website contains a number of videos hosted on Silverlight Streaming. In addition to knowing which videos your users are playing, you may well want to know how often these videos were paused and restarted or stopped prior to completion. The Silverlight Analytics Library represents a C# wrapper on the GA Event Tracking interface which permits a developer to choose one of three overloaded TrackEvent methods to pass in the required Category and Action parameters with or without either or both of the optional parameters, Label and Value. Each of these methods assumes that an EventTracker object has been created with a constructor which specifies the applicable Category.
public void TrackEvent(TAction action) { if
(Tracker != null) { Tracker.Invoke("_trackEvent",
Category.ToString(),
action.ToString()); } } public
void TrackEvent(TAction action,
String label) { if
(Tracker != null) { Tracker.Invoke("_trackEvent",
Category.ToString(),
action.ToString(),
label); } } public
void TrackEvent(TAction action,
String label,
int value) { if
(Tracker != null) { Tracker.Invoke("_trackEvent",
Category.ToString(),
action.ToString(),
label, value); } } To use the Silverlight Analytics Library, all you need to do is to include the same JavaScript reference to Google Analytics web tracking which is described at the beginning of the New Web Tracking Method section, above. Then add a reference to the SilverlightAnalytics.dll to your Silverlight application. Next you will want to create enums to hold your lists of Categories and Actions. Then in your event handlers for the events you want to track, create an instance of the SilverlightAnalytics EventTracker class and call one of the three methods specified above with the necessary parameters. From the GA Event Tracking reports it would then be possible to determine the aggregate number of how many users viewed any video, the number of users who viewed each individual video, and for each video, how many users pressed Play, Pause or Stop—and how many times. Moreover, if each of these Labels (Play, Pause, Stop) were assigned a numerical value (via the Value parameter), aggregate values could be determined for and across each Label. Accordingly, when and if GA Event Tracking becomes publicly available, a significant additional level of potentially useful tracking detail should become available. The Silverlight Analytics Library also contains a method which permits tracking on both a real and pseudo pageview basis comparable to the method described in the New Web Tracking Method section above. Overloads permit the passage of either a Uri or a string.
public void TrackPageview(Uri pageUrl) { TrackPageview(pageUrl.ToString()); } public void TrackPageview(String pageUrl) { Tracker.Invoke("_trackPageview",
pageUrl); } Justin Cutroni has prepared a good three part series explaining how to use Google Analytics Event Tracking. Please note that there have been some changes to the GA Event Tracking structure since the Cutroni articles were written, particularly that the "_trackEvent" method can now be called directly from the pageTracker object rather than having to instantiate a separate eventTracker object for each category that you want to track. Finally, it should be noted that while the Silverlight Analytics Library offers the convenience of calling GA Event Tracking directly from inside a C# event handler, it would also be possible to call GA Event Tracking indirectly by calling a JavaScript function from the C# event handler using a technique similar to that described in the New Web Tracking Method section above. Generally, however, you will find the Silverlight Analytics Library approach to be much more convenient, particularly if you are uncomfortable with JavaScript. Summary Also since standard tracking mechanisms for web analytics are very much page oriented, in the case of Silverlight content it is necessary to use a pseudo page approach. As it turns out, this approach is relatively easy to implement and gives you great flexibility in how you create the structure that you can use to organize your tracking information. Any event—from a button click to a list box selection, even a mouseover—can be assigned a pseudo page identity and tracked in the same fashion as the navigation to a different web page. With this tracking information, a site administrator or a website developer is in a position to continually improve the design of the website to enhance visitor experiences and, more importantly, to increase the website's contribution to the organization in achieving its overall business goals. Links * This article was commissioned by and prepared for Microsoft Corporation. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
|
||||
|
Cal Schrotenboer is a C# developer with experience in building Windows Forms
application front ends for SQL Server databases. He also teaches programming classes at Foothill College in Los Altos Hills, California and Microsoft Network Administration (MCSE) classes at Mission College in Santa Clara. Cal maintains a WPF blog at www.WPFLearningExperience.com. His outside interests include travel
and photography (www.travelswithcal.com).
| ||||
|
||||
|
|