do { Engine.BlogAbout(".NET","Silverlight"); } while ( alive );  

Mark Monster

Mark Monster  

Tracking Silverlight support in Google Analytics

I think that a lot of people make use of Google Analytics for their site statistics. I am one of those Google Analytics users. You can easily dive into the statistics. Like checking the amount of visitors that have support for Java or Flash. But sadly Google still doesn’t track the support of Silverlight. So I though let’s dive into getting some statistics about Silverlight support in Google Analytics.

How to track custom data in Google Analytics?

You can easily track custom data. You can do things just like this. A very simple track would be something like:

pageTracker._trackPageview(”/tracking/tryout”);

How to check support for Silverlight?

The check for Silverlight support isn’t that difficult as well. You will just need to reference Silverlight.js. And after that there will be a new function available called Silverlight.isInstalled. This function accepts a string which contains the version number. We can use it like this.

Silverlight.isInstalled(’1.0′);

or

Silverlight.isInstalled(’2.0′);

Combined: check for Silverlight support and tracking in Google Analytics

The combination of both the Google Analytics tracking with Silverlight support will looks like this (make sure you change the location of Silverlight.js and your Google Analytics tracking code).

<script type=”text/javascript” src=”/Javascript/Silverlight.js”>
</script>
<script type=”text/javascript”>
var gaJsHost = ((”https:” == document.location.protocol) ? “
https://ssl.” : “http://www.”);
document.write(unescape(”%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-xxxxx-x”);
pageTracker._trackPageview();
var hasSilverlight = Boolean(window.Silverlight);
var hasSilverlight1 = hasSilverlight && Silverlight.isInstalled(’1.0′);
var hasSilverlight2 = hasSilverlight && Silverlight.isInstalled(’2.0′);
if (hasSilverlight1) {
pageTracker._trackPageview(”/silverlightsupport/v1/support”);
}
else {
pageTracker._trackPageview(”/silverlightsupport/v1/nosupport”);
}
if (hasSilverlight2) {
pageTracker._trackPageview(”/silverlightsupport/v2/support”);
}
else {
pageTracker._trackPageview(”/silverlightsupport/v2/nosupport”);
}
</script>

How does it look like?

Content Drilldown - /silverlightsupport/v1
Support: 50%
No support: 50%

image

Content Drilldown - /silverlightsupport/v2
Support: 49%
No support: 51%

image

The statistics say that about 50% of the visits I get have support for Silverlight 1 and 2. But it’s important to know these stats are just from one days data. For real statistics you need at least weeks or maybe even months of data.

PS. Sorry for the bad code-snippets. I have always been using the very nice Live Writer plugin from Steve Dunn. But this plugin doesn’t work anymore in the latest version of Live Writer.

Update February 25th 2009: Szabi has written an excellent addition to this article.

8 Responses to “Tracking Silverlight support in Google Analytics”

  1. Silverlight Travel » Tracking Silverlight support in Google Analytics Says:

    [...] The combination of both the Google Analytics tracking with Silverlight support will looks like this (make sure you change the location of Silverlight.js and your Google Analytics tracking code).  more here [...]

  2. Silverlight Travel Says:

    Hi Mark,
    Thanks for the correction.
    I changed the link to your blog.

    Regards
    Peter Loebel
    Switzerland

  3. timheuer Says:

    I also wrote about this in December relative to the new “event” feature in GA — which would be more relative to RIA end-user activity tracking: http://timheuer.com/blog/archive/2008/12/04/analytics-web-tracking-with-silverlight.aspx

  4. Mark Monster Says:

    Hi Tim,

    That’s really a nice article. That’s more specially related to event tracking in applications. Good to know this functionality of GA. I will keep it my mind for my next RIA project.

  5. helloszabi Says:

    Hi Mark!

    Thanks for your script, it’s really helpful, but my opinion is that tracking Silverlight support as virtual pageviews isn’t the best solution. Event trackig looks far more better and events don’t distort pageview charts.

    So I made a little modification and posted it here: http://helloszabi.com/post/81116183/silverlight-tracking-with-google-analytics

    Cheers,
    Szabi

  6. Logging Navigation in the Silverlight 3 Beta « davidpoll.com Says:

    [...] Mark Monster has a great post from a few months ago on his blog about tracking Silverlight support in Google Analytics.  I imagine you could use a similar technique to accomplish the type of logging I do [...]

  7. Top-silverlight » Blog Archive » Logging Navigation in the Silverlight 3 Beta Says:

    [...] Monster has a great post from a few months ago on his blog about tracking Silverlight support in Google Analytics.  I imagine you could use a similar technique to accomplish the type of logging I do here. [...]

  8. Tracking Silverlight (1, 2 and 3) support in Google Analytics « Mark Monster Says:

    [...] a year ago I blogged about tracking Silverlight support in Google Analytics. I’ve had a lot of reactions on how to track Silverlight support. In my original article I made [...]

Leave a Reply