Friday, April 11, 2008

Tracking Silverlight visits with WebTrends

Are you thinking about adding Microsoft Silverlight to your site? Need to know the percent of visits that have Silverlight installed? Well then, this is the post for you. Microsoft has done a great job with its latest release, version 2.0. There are a lot of great built-in methods for tracking video plays, stops, re-buffers and more (don't worry, I will go into all of this in the coming weeks). But, as with any site or creative, it is important to understand your visitors. To get this, we will need to make an update to the WebTrends JavaScript include.

Within your WebTrends JavaScript include you will want to add the following code to the dcsVar() function within your tag.

WT.sli=(function(){
try{
if(navigator.userAgent.indexOf('MSIE')!=-1){
var sli = new ActiveXObject('AgControl.AgControl');
if(sli){return "Yes";}
}
else{
if (navigator.plugins["Silverlight Plug-In"]){
return "Yes";
}
}
}
catch(e){}
return "No";
})();
WT.slv=(function(){
var i,j,slv;
if ((typeof(Silverlight)=="object")&&(typeof(Silverlight.isInstalled)=="function")){
for(j=9;j>=0;j--){
for(i=3;i>0;i--){
slv=i+"."+j;
if (Silverlight.isInstalled(slv)){
return slv;
}
}
}
}
return "n/a";
})();

Once the tag has been updated, you should see the WT.sli and WT.slv parameters being passed. The WT.sli parameter will define whether or or not Silverlight is installed and the WT.slv parameter will define the version. As an FYI, the Silverlight version does not make itself apparent unless a Silverlight creative has been instantiated on the page.

The rest is really up to you for report creation. I would recommend a 2d report with D1 set to WT.sli, D2 set to WT.slv with Visits and Percent of Visits as the measures. This will be a quick way to measure those who have Silverlight.

Hope this helps!

-W

No comments: