Archives

 

Detect Silverlight and Flash with SiteCatalyst Plugin

Tracking your visitor’s Flash version is nothing new. I wrote about it a while ago in the Plugin To Detect Flash in SiteCatalyst post. What I have here is a little more powerful. This is the Rich Internet Application tracking plug-in.

RIA development is becoming more and more popular. Do your Visitors have Flash? What version? How about SilverLight? What version of that? Do they have both? Now you will know. What this SiteCatalyst plug-in does is detects the Silverlight version, and the Flash version. If you want to see it in action, fire up your Omniture JavaScript debugger on this page. You will see s.prop10 and s.prop11 (c10 and c11) populated with the Flash version and Silverlight versions your browser has installed. You will also see the Flash version populated in s.prop9 (c9). This is done using the original flash detection plug-in mentioned above.

Here is how to use it. First in the s_code.js file call the plug-in along with the variables you want to use to store the visitors rich application versions. Here I am using s.prop10 and s.prop11:

s.detectRIA('s_ria','prop10','prop11'); 

Then in the plug-in’s section add the plug-in code:

/*
 * Plugin: detectRIA v0.1 - detect and set Flash, Silverlight versions
 */
s.detectRIA=new Function("cn", "fp", "sp", "mfv", "msv", "sf", ""
+"cn=cn?cn:'s_ria';msv=msv?msv:2;mfv=mfv?mfv:10;var s=this,sv='',fv=-"
+"1,dwi=0,fr='',sr='',w,mt=s.n.mimeTypes,uk=s.c_r(cn),k=s.c_w('s_cc',"
+"'true',0)?'Y':'N';fk=uk.substring(0,uk.indexOf('|'));sk=uk.substrin"
+"g(uk.indexOf('|')+1,uk.length);if(k=='Y'&&s.p_fo('detectRIA')){if(u"
+"k&&!sf){if(fp){s[fp]=fk;}if(sp){s[sp]=sk;}return false;}if(!fk&&fp)"
+"{if(s.pl&&s.pl.length){if(s.pl['Shockwave Flash 2.0'])fv=2;x=s.pl['"
+"Shockwave Flash'];if(x){fv=0;z=x.description;if(z)fv=z.substring(16"
+",z.indexOf('.'));}}else if(navigator.plugins&&navigator.plugins.len"
+"gth){x=navigator.plugins['Shockwave Flash'];if(x){fv=0;z=x.descript"
+"ion;if(z)fv=z.substring(16,z.indexOf('.'));}}else if(mt&&mt.length)"
+"{x=mt['application/x-shockwave-flash'];if(x&&x.enabledPlugin)fv=0;}"
+"if(fv<=0)dwi=1;w=s.u.indexOf('Win')!=-1?1:0;if(dwi&&s.isie&&w&&exec"
+"Script){result=false;for(var i=mfv;i>=3&&result!=true;i--){execScri"
+"pt('on error resume next: result = IsObject(CreateObject(\"Shockwav"
+"eFlash.ShockwaveFlash.'+i+'\"))','VBScript');fv=i;}}fr=fv==-1?'flas"
+"h not detected':fv==0?'flash enabled (no version)':'flash '+fv;}if("
+"!sk&&sp&&s.apv>=4.1){var tc='try{x=new ActiveXObject(\"AgControl.A'"
+"+'gControl\");for(var i=msv;i>0;i--){for(var j=9;j>=0;j--){if(x.is'"
+"+'VersionSupported(i+\".\"+j)){sv=i+\".\"+j;break;}}if(sv){break;}'"
+"+'}}catch(e){try{x=navigator.plugins[\"Silverlight Plug-In\"];sv=x'"
+"+'.description.substring(0,x.description.indexOf(\".\")+2);}catch('"
+"+'e){}}';eval(tc);sr=sv==''?'silverlight not detected':'silverlight"
+" '+sv;}if((fr&&fp)||(sr&&sp)){s.c_w(cn,fr+'|'+sr,0);if(fr)s[fp]=fr;"
+"if(sr)s[sp]=sr;}}");
s.p_fo=new Function("n",""
+"var s=this;if(!s.__fo){s.__fo=new Object;}if(!s.__fo[n]){s.__fo[n]="
+"new Object;return 1;}else {return 0;}");

“We are considering developing some Silverlight applications. What percentage of our visitors have Silverlight, and if so what version?” Now you will have no problems answering that question.

If you would like more information about using SiteCatalyst with Silverlight, check out the white paper Using SiteCatalyst and Silverlight, available in the Omniture Knowledge Base.

Enjoy!

Plugin To Detect Flash in SiteCatalyst

I was reading a post earlier today on the Omniture Industry Insights site about Flash version detection. In the post, Technical Writer extraordinaire Ben Gaines explains a few methods on how to ‘detecting the version of Adobe Flash Player that visitors have installed in their browsers’. He states there are many methods readily available by doing a simple search, and there are. If you don’t have the skills or patience to hunt around for a way to grab the flash version, let me serve on right up on a silver platter for you. Behold, the Flash Detection plugin.

In your s_code file, add the following call to populate the sprop or evar of your choice

s.prop9=s.getFlash('s_fv');
	if(!s.prop9){
		s.detectFlash('s_fv','10');
		s.prop9=s.getFlash('s_fv');
	}

Then down in the plugin’s section, add the following code

/*
 * Plugin: Flash Detection 0.6 - Detect Flash version number
 */
s.detectFlash=new Function("cn","mfv","vr",""
+"var s=this,fv=-1,dwi=0,r,w,mt=s.n.mimeTypes,fk=s.c_r(cn),k=s.c_w('s"
+"_cc','true',0)?'Y':'N';if(k=='Y'&&!fk){if(s.pl&&s.pl.length){if(s.p"
+"l['Shockwave Flash 2.0'])fv=2;x=s.pl['Shockwave Flash'];if(x){fv=0;"
+"z=x.description;if(z)fv=z.substring(16,z.indexOf('.'));}}else if(mt"
+"&&mt.length){x=mt['application/x-shockwave-flash'];if(x&&x.enabledP"
+"lugin)fv=0;}if(fv<=0)dwi=1;w=s.u.indexOf('Win')!=-1?1:0;if(dwi&&s.i"
+"sie&&w&&execScript){result=false;for(var i=mfv;i>=3&&result!=true;i"
+"--){execScript('on error resume next: result = IsObject(CreateObjec"
+"t(\"ShockwaveFlash.ShockwaveFlash.'+i+'\"))','VBScript');fv=i;}}r=f"
+"v==-1?'flash not detected':fv==0?'flash enabled (no version)':'flas"
+"h '+fv;s.c_w(cn,r,0);return 'true';}else return '';");
s.getFlash=new Function("cn",""
+"var s=this;if(cn&&s.c_r(cn))return s.c_r(cn);");
s.returnFlash=new Function("cn","vr","to",""
+"setTimeout(\"var cn,vr,to,s_dfv=s_gi(s_account);s_dfv.linkTrackVars"
+"=vr,s_dfv.vr=s.getFlash();s_dfv.tl(this,'o','Flash Version Detectio"
+"n')\",to);");

If you have the SiteCatalyst debugger, go ahead and fire it up right now and you will see that I have this plugin enabled here populating s.prop9.

Enjoy!