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
s.getNewRepeat(d,c);

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.

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

s.prop1=s.getNewRepeat(60,'s_gnr');

Code

/*
 * 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:"
+"'s_nr';e.setTime(ct+d*24*60*60*1000);cval=s.c_r(cn);if(cval.length="
+"=0){s.c_w(cn,ct+'-New',e);return'New';}sval=s.split(cval,'-');if(ct"
+"-sval[0]<30*60*1000&&sval[1]=='New'){s.c_w(cn,ct+'-New',e);return'N"
+"ew';}else{s.c_w(cn,ct+'-Repeat',e);return'Repeat';}");