SiteCatalyst Plug-ins

Here is a collection of Omniture SiteCatalyst plug-ins that I have found to be pretty useful. The documentation should be pretty straight forward. If there are any questions please feel free to contact me with any questions you may have.

Remember, make sure you fully test them in your development environment before using them on a live site.

apl (Append List)

Append values to a list.

Read and Write Combined Cookies

These plug-ins reduces the number of cookies that SiteCatalyst will set.

detectRIA (Rich Internet Applications)

Detect the versions of Flash and Silverlight installed in visitors browsers.


Captures the value of a variable and passes it into another variable on every page view.


Sets the Cart Open event on the first instance of the Cart Add event being set.


Capture the number of days since the user last visited your site.


Capture folder name values from the URL.


Captures if a user on your site is a new visitor or a repeat visitor.


Captures the value from the previous page and records it on the current page.


Capture values (eg. tracking codes) from the query string of your page URLs.


Records time segments based on the hour of day, day of the week or weekend/weekday.


Ensures that designated variables are populated with a given value only once per specified time period.


Returns the total number of visits that the user has made to your site.


Used to determine first page of a visit.


Resets the effects of the getCartOpen plug-in.

Capture Mobile Device Screen Orientation In SiteCatalyst

Recently I was speaking to someone who was in the process of creating an tablet experience for their visitors. At one point they asked the question “of my iPad visitors, how do I find out in what format do they view my site the most in, landscape or portrait?”. I started going through all of the reports in SiteCatalyst and tried to find the answer, but that information just was not available. So I decided to whip a little bit of code that would figure this out for us. I call this the screenOrientation plug-in.

Basically what this will do is it will check to see in what position the mobile visitor is viewing the site in, whether they are viewing the site in a portrait or a landscape view when the page loads, and capture that value into a SiteCatalyst variable.

To implement this plug-in you first need to take this code, and add it to your s_code file near the rest of your plug-ins.

function screenOrientation(){switch(window.orientation){case 0:case 180:return("Portrait");break;case 90:case -90:return("Landscape");}window.scroll(0,0)}

Next in the do_plugins section of the s_code file, add the call to the plug-in to what ever SiteCatalyst variable you want this data captured in. In the example here you can see I am capturing it in s.prop1


Thats all it takes. Once the code is implemented, if the device does not have an orientation value the variable will not capture anything, but if the visitor is on a mobile device with an orientation value, the value of Landscape or Portrait will be captured on each page load. You will end up with a report that looks something like this:

Mobile Screen Orientation Report

To make it easier to access the report I also moved it into the Mobile report menu by using the customize menus option in the admin console of SiteCatalyst.

SiteCatalyst Mobile Reports


Bounce Rate Funnels – Action Depth SiteCatalyst Plug-In

Bounce Rates. For those of you who are unaware of what they are, bounce rate is essentially the percentage of single page visits, divided by your total visits. This metric can be pretty useful to figure out what pages of your site that your visitors enter on and decide not to venture any deeper into your site. Basically the visitor came to your site and the page they entered on did not entice them to view additional pages of your site so they left. This is obviously not what we want. We need our visitors to come to our sites and complete our desired action. This is where I run into a problem with the Bounce Rate metric. Lets say for example you have a lead generation site, which contains a form on the landing page which uses ajax or some other type of technology to process the form submission. That site would have a visitor enter, fill out the form (which is your desired action) and then leave the site. This would show up as a bounced visit since a second page view was not recorded. What can we do to record this action as a successful visit and not have it end up being considered as just another bounce?

One thing you could do would be to use the getVisitStart plug-in. With this plug-in you could set an event on the first page of the visit, and then using a conversion funnel you can see how many visits entered on your specified landing page and then completed your conversion event.

Pretty simple stuff so far. But what if I wanted to now know how many of those visits ventured on to view additional pages of my site, and how many left right after completing my conversion event? For this I would want to set a second different success event on the second page view of the site. For this we can use the getActionDepth plug-in.

What this plug-in will do is set a success event (or any SiteCatalyst variable you want) onto any page of the visit. In this case we want to set a success event on the second page view of the site. Using the Action Depth plug-in we can set individual events on only the first page view and the second page view of the visit. Now using the same conversion funnel we can see how many visits entered the site, completed our conversion action, and then stayed to view a second page of the site.

What if your site does not have an ajax type form conversion action and you just want to use the custom events funnel as a cool way to display how many bounces your site had? That can also be easily done.

By just including the event that fired on page 1 of the visit and the event that fired on the second page view of the visit we now have a nice graphical representation of how many of our visits left after viewing a single page and how many decided to move on to view additional pages of the site.

What if for your site only viewing 2 pages was not good enough? You need to see what percentage of your visits see at least three pages. The Action Depth plug-in can take care of that as well.

Now if you have spent more than couple minutes using SiteCatalyst you could probably be saying to yourself “I can find this information out already by using the Path Length report”. Yes that report will tell you what percentage of your visits saw any number of pages, but have you tried to add that report to a dashboard? It’s not pretty. This way you can easily show the exact information you need in a very easy to read format.

Let’s take a look at what the plug-in code looks like If we want to set an event on first page view of the visit, and another one on the second page view of the visit. First add this line in the top of your s_code file, in the config section.


Next this call to the plug-in should be placed in your s_code file in the s_doPlugins section.

	if(s.pdvalue == 1) {,'event1',',',1)
	if(s.pdvalue == 2) {,'event2',',',1)

And here is the actual plug-in that should be placed after the s_doPlugins section, along with your other plug-ins.

 * Plugin: getActionDepth v1.0
s.getActionDepth=new Function("c",""
+ "var s=this,v=1,t=new Date;t.setTime(t.getTime()+1800000);"
+ "if(!s.c_r(c)){v=1}if(s.c_r(c)){v=s.c_r(c);v++}"
+ "if(!s.c_w(c,v,t)){s.c_w(c,v,0)}return v;");

But there is one more thing (sorry I was feeling very Steve Jobs for a moment). Actually I have two more things but I couldn’t pass up on a good Steve Jobs reference. Let’s say you also need to set an additional event and an eVar on the 6th page view of the site, and only on the 6th page view. That can easily be done as well by just changing somethings around in the plug-in code. By looking at the call to the plug-in it should be pretty easy to see what’s going on. When the specific page view of the visit is reached, then the actions that are attached will occur.

	if(s.pdvalue == 1) {,'event1',',',1)
	if(s.pdvalue == 2) {,'event2',',',1)
	if(s.pdvalue == 6) {,'event3',',',1)
	        s.eVar="This is the sixth page view";

Now how about you want to know how many page views deep do your visitors go when they complete your conversion action. A little change to the plug-in code and we can capture that as well. What we do here is just capture what the page number of the visit is on each page view in an eVar, then we can just add in our conversion event to that report and there we go. Then we can see directly in our optimization efforts if we are helping our visitors quickly get to our conversion event. Here is the code to capture the page number of each page of the visit in an eVar.

	if(s.pdvalue) {


Combined Cookies SiteCatalyst Plug-in

These plug-ins reduces the number of cookies that SiteCatalyst will set.

Plug-in Prototype
There is no call that needs to be made to these plug-ins. Just add them to the plug-in’s section of your s_code file and you are all done.


 * Function - read combined cookies v 0.3
if(!s.__ccucr){s.c_rr=s.c_r;s.__ccucr = true;
s.c_r=new Function("k",""
+"var s=this,d=new Date,v=s.c_rr(k),c=s.c_rr('s_pers'),i,m,e;if(v)ret"
+"urn v;k=s.ape(k);i=c.indexOf(' '+k+'=');c=i<0?s.c_rr('s_sess'):c;i="
+"c.indexOf(' '+k+'=');m=i<0?i:c.indexOf('|',i);e=i<0?i:c.indexOf(';'"
+"urn v;");}
 * Function - write combined cookies v 0.3
if(!s.__ccucw){s.c_wr=s.c_w;s.__ccucw = true;
s.c_w=new Function("k","v","e",""
+"this.new2 = true;"
+"var s=this,d=new Date,ht=0,pn='s_pers',sn='s_sess',pc=0,sc=0,pv,sv,"
+"c,i,t;d.setTime(d.getTime()-60000);if(s.c_rr(k)) s.c_wr(k,'',d);k=s"
+".ape(k);pv=s.c_rr(pn);i=pv.indexOf(' '+k+'=');if(i>-1){pv=pv.substr"
+".indexOf(' '+k+'=');if(i>-1){sv=sv.substring(0,i)+sv.substring(sv.i"
+"ndexOf(';',i)+1);sc=1;}d=new Date;if(e){if(e.getTime()>d.getTime())"
+"{pv+=' '+k+'='+s.ape(v)+'|'+e.getTime()+';';pc=1;}}else{sv+=' '+k+'"
+"='+s.ape(v)+';';sc=1;}if(sc) s.c_wr(sn,sv,0);if(pc){t=pv;while(t&&t"
+".indexOf(';')!=-1){var t1=parseInt(t.substring(t.indexOf('|')+1,t.i"
+"Time(ht);s.c_wr(pn,pv,d);}return v==s.c_r(s.epa(k));");}

getPreviousValue SiteCatalyst Plug-in

The getPreviousValue plug-in captures the value from the previous page and records it on the current page.

Plug-in Prototype

Parameter Descriptions
v = variable to be captured from the previous page.
c = cookie name for use in storing the value.
e = events which must be set on the page view in order to trigger the retrieval of the previous value. When omitted, the plug-in will capture the previous value on all page views.

Here is how to capture the page name value of the previous page into prop1 when event 1 is set on the current page.



 * Plugin: getPreviousValue_v1.0 - return previous value of designated
 * variable (requires split utility)
s.getPreviousValue=new Function("v","c","el",""
+"var s=this,t=new Date,i,j,r='';t.setTime(t.getTime()+1800000);if(el"
+"){if({i=s.split(el,',');j=s.split(,',');for(x in i"
+"){for(y in j){if(i[x]==j[y]){if(s.c_r(c)) r=s.c_r(c);v?s.c_w(c,v,t)"
+":s.c_w(c,'no value',t);return r}}}}}else{if(s.c_r(c)) r=s.c_r(c);v?"
+"s.c_w(c,v,t):s.c_w(c,'no value',t);return r}");

getNewRepeat SiteCatalyst Plug-in

The getNewRepeat plug-in determines whether a user on your site is a new visitor or a repeat visitor.

Plug-in Prototype

Parameter Descriptions
d = number of days the cookie should last. It will default to 30 days if argument is omitted.
c = cookie name. A default value will be used if this argument is omitted.

Here is how you would populate a prop with the New or Repeat value, based on the last 60 days.



 * Plugin: getNewRepeat 1.2 - Returns whether user is new or repeat
s.getNewRepeat=new Function("d","cn",""
+"var s=this,e=new Date(),cval,sval,ct=e.getTime();d=d?d:30;cn=cn?cn:"

getDaysSinceLastVisit SiteCatalyst Plug-in

The getDaysSinceLastVisit plug-in determines the number of days since a user last visited your site.

Plug-in Prototype

Parameter Descriptions
c=Name of the cookie that the plug-in will set.

Here is an example use of the plug-in to capture the number of days since the visitor last visited your site.



 * Plugin: Days since last Visit 1.1 - capture time from last visit
s.getDaysSinceLastVisit=new Function("c",""
+"var s=this,e=new Date(),es=new Date(),cval,cval_s,cval_ss,ct=e.getT"
+"etTime(ct+30*60*1000);f0='Cookies Not Supported';f1='First Visit';f"
+"2='More than 30 days';f3='More than 7 days';f4='Less than 7 days';f"
+"5='Less than 1 day';cval=s.c_r(c);if(cval.length==0){s.c_w(c,ct,e);"
+"s.c_w(c+'_s',f1,es);}else{var d=ct-cval;if(d>30*60*1000){if(d>30*da"
+"y){s.c_w(c,ct,e);s.c_w(c+'_s',f2,es);}else if(d<30*day+1 && d>7*day"
+"){s.c_w(c,ct,e);s.c_w(c+'_s',f3,es);}else if(d<7*day+1 && d>day){s."
+"c_w(c,ct,e);s.c_w(c+'_s',f4,es);}else if(d<day+1){s.c_w(c,ct,e);s.c"
+"+'_s',cval_ss,es);}}cval_s=s.c_r(c+'_s');if(cval_s.length==0) retur"
+"n f0;else if(cval_s!=f1&&cval_s!=f2&&cval_s!=f3&&cval_s!=f4&&cval_s"
+"!=f5) return '';else return cval_s;");

getTimeParting SiteCatalyst Plug-in

Records time segments based on the hour of day, day of the week or weekend/weekday.

Plug-in Prototype

Parameter Descriptions
x=’h’ (hour of day),’d’ (day of week),’w’ (weekend / weekday)
tz=timezone (example ‐5 New York)

Here is an example use of the plugin to populate the hour of day in s.prop1, the day of week in s.prop2, and if it is either the weekday or weekend in s.prop3.



 * Plugin: getTimeParting 3.0 - Set timeparting values based on time zone - valid through 2014 
s.getTimeParting=new Function("t","z",""
+"var s=this,d,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T;d=new Date();A"
+"';C='01'}B='03/'+B+'/'+A;C='11/'+C+'/'+A;D=new Date('1/1/2000');if("
+"D.getDay()!=6||D.getMonth()!=0){return'Data Not Available'}else{z=p"
+"arseFloat(z);E=new Date(B);F=new Date(C);G=F;H=new Date();if(H>E&&H"
+"ew Date(I+(3600000*z));K=['Sunday','Monday','Tuesday','Wednesday','"
+"+P;if(t=='h'){return T}if(t=='d'){return O}if(t=='w'){return Q}}");

getVisitNum SiteCatalyst Plug-in

Returns the total number of visits that the user has made to your site.

Plug-in Prototype

Here is an example use of the plugin to take the number of the visit and place that value in the variable shown.



 * Plugin: getVisitNum - version 3.0
s.getVisitNum=new Function("tp","c","c2",""
+"var s=this,e=new Date,cval,cvisit,ct=e.getTime(),d;if(!tp){tp='m';}"
+"me(y);}else {d=tp*86400000;e.setTime(ct+d);}if(!c){c='s_vnum';}if(!"
+"c2){c2='s_invisit';}cval=s.c_r(c);if(cval){var i=cval.indexOf('&vn="
+"t){if(str){e.setTime(ct+1800000);s.c_w(c2,'true',e);return str;}els"
+"e {return 'unknown visit number';}}else {if(str){str++;k=cval.substri"
+"s.c_w(c2,'true',e);return str;}else {s.c_w(c,e.getTime()+'&vn=1',e)"
+";e.setTime(ct+1800000);s.c_w(c2,'true',e);return 1;}}");
s.dimo=new Function("m","y",""
+"var d=new Date(y,m+1,0);return d.getDate();");
s.endof=new Function("x",""
+"var t=new Date;t.setHours(0);t.setMinutes(0);t.setSeconds(0);if(x=="
+"'m'){d=s.dimo(t.getMonth(),t.getFullYear())-t.getDate()+1;}else if("
+"x=='w'){d=7-t.getDay();}else {d=1;}t.setDate(t.getDate()+d);return "