Omniture SiteCatalyst getVisitNum Custom plugin
Here is a cool plugin that allows you to capture visit number by daily, weekly, and monthly visit and pass into traffic and commerce variables. This plugin comes in handy for those who want to see how visit number trends by visit and then correlate that with various KPI (searches, content consumption, products viewed, etc).* This plugin isn’t provided by Omniture so please make sure that you properly test this prior to releasing this code. I will not be held responsible for any errors in coding this might cause to your customized settings. Please test!Name of Plug-in: getVisitNumCustomVersion of Plug-in: c1.0 –> the c indicates customPurpose of Plug-in: This plug-in allows the capture of visit number by daily, weekly or monthly visit.How to implement plug-in:
-
Form Analysis Config (should be above doPlugins section) */s.formList=”"s.trackFormList=trues.trackPageName=trues.useCommerce=trues.varUsed=”"s.eventList=”" //Abandon,Success,Error
- Add the following line to the doPlugins section of the s_code.js file
/*Get Visit Numbers - For Visitor Profiling*/s.prop1=s.evar1=s.getVisitNumCustom('d'); // daily visitss.prop2=s.evar2=s.getVisitNumCustom('w'); // weekly visits.prop3=s.eVar3=s.getVisitNumCustom('m'); // monthly visits
At the end of the plug-in section, just before the “DO NOT ALTER” line, place the following code:
/**Plugin: getVisitNum custom plugin v.1.0 - Captures visit number by day week and month and pass into props*/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 t;");s.getVisitNumCustom=new Function("tp", ""+"var s=this,e=new Date(),cval,cvisit,ct=e.getTime(),c='s_vnum_'+tp,c2='sinvisit_'+tp,eo=s.endof(tp),"+"y=eo.getTime();e.setTime(y);cval=s.c_r(c);if(cval){var i=cval.indexOf('&vn='),str=cval.substring(i+4,cval.length),k;}"+"cvisit=s.c_r(c2);if(cvisit){if(str){e.setTime(ct+30*60*1000);s.c_w(c2,'true',e);return str;}"+"else return 'unknown visit number';}"+"else{if(str){str++;k=cval.substring(0,i);e.setTime(k);s.c_w(c,k+'&vn='+str,e);e.setTime(ct+30*60*1000);s.c_w(c2,'true',e);return str;}"+"else{s.c_w(c,y+'&vn=1',e);e.setTime(ct+30*60*1000);s.c_w(c2,'true',e);return 1;}}");
Typical Correlations that can be set up from this plug-in:
- getVisitNum by top content
- getVisitNum by searches
- getVisitNum by success event
Written by:
Dorian D. Regester
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

