Earlier this year, Michael Scherotter and William Garrison produced an excellent article on "Using Web Analytics with Microsoft Silverlight". The Scherotter/Garrison article was targeted at Silverlight 1.0 and given the recent release of Silverlight 2 RC0, and the even more recent final release of Silverlight 2, the time appears ripe for an update to this topic to address the issue of how to effectively use web analytics with Microsoft Silverlight 2.
Web analytics is essentially a tool for measuring and evaluating web site traffic in order to determine some mix of the following:
- Which promotional campaigns are the most effective and which are not
- From what source (search engines, blogs, newsgroups, cross-listings, etc.) do site visitors come
- Which products or services offered by the site have the highest (and lowest) browse to buy ratios (which products does a website help sell the most of)
- What types of visitors are most likely (or least likely) to become buyers, subscribers or members
- Which products or services are most promising for cross-selling opportunities ("Customers who bought product X also bought product Y...")
- Where do most visitors enter the website, what pathways do they most frequently follow and from where do they most often abandon the website
- How successful is any new content, style or structural changes
- What keywords do visitors use most often when searching for something within the site
- What broken links or other errors does the site contain
The language of Web analytics includes:
- Hits - a frequently misleading statistic referring to the total number of files accessed from a website (a single page which contains 9 images—including navigational icons for example—would generate 10 hits per page view)
- Pageviews - a measurement of how many pages (.htm, .aspx, .php, etc.) were requested within a given time frame
- Unique Visitors - a calculation of how many different people (generally determined by IP Address) visit a web site during the measurement period
- Visits (or Sessions) - a sequence of requests from a single visitor until the point of site abandonment
Web analytics services take the raw data collected from a given website and display it in a collection of reports which are designed to permit a site administrator to evaluate the performance of the website pursuant to the criteria described above.
 | |
| Figure 1. This screenshot from Google Analytics shows 352 visits by 253 unique visitors with 990 pageviews during the applicable tracking period. Hits are not displayed. |
There are a number of commercial and free Web analytics options including WebTrends, Omniture, Microsoft AdCenter Analytics (currently in Beta with only limited public availability) and Google Analytics, but in the interest of space, I will confine my examples to Google Analytics. The principles of these examples should generally be applicable to other Web analytics solutions as well.
Click-Stream Tracking for Silverlight 2 Applications
Obviously understanding your customers and how they react to your website is just as important for a website with Silverlight content as one without. For example, it could be very useful to a site administrator to know what percentage of users choose the "Skip Introduction" link or how often users click on the "Instructions" button.
 | |
| Figure 2. This screenshot shows a typical single page Silverlight application with an animated introduction and a button for displaying usage instructions. |
However, the measurement process for Web analytics is linked to navigation through multiple web pages and Silverlight content frequently compresses user interaction into a single page. Thus, in order to generate an accurate view of user activity with respect to Silverlight content, a modified analytics implementation is required.
Google has two versions for the tracking code required to monitor websites which it refers to as the old (or legacy) method (urchin.js) and the new method (ga.js). This article will illustrate how to interface between Silverlight content and Google Analytics using either method, the older one first.