How can I use the daysSinceLastVisit-plugin within DTM?



I understand that I have to place the code in the custom page code editor of the tool. 

So now I have the following code, but I still don't see the dslv cookie being set. Maybe this is a terrible stupid question, but I'm no developer so I can't figure out what is going wrong. 

Please help me out guys! I buy you lunch.

The code:

function s_doPlugins(s){
    s.prop45 = s.getDaysSinceLastVisit("dslv");

/* 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;");

Accepted Solutions (1)

Accepted Solutions (1)



Only difference that I have on mine which might be worth a try is:

s.usePlugins=true s.doPlugins=function(s) { /* Add calls to plugins here */ s.prop45 = s.getDaysSinceLastVisit('sc_dslv'); }

Answers (2)

Answers (2)



Hi Guido,

It is  necessary to use s.usePlugin=true;  before the s.doPlugins=function{} call. If s.usePlugin is not used or set to false s.usePlugin=false; then the code written inside doplugins function is ignored.

@ Andrew Roberts (arob87) Thanks for sharing your code.

Thanks & Regards

Parit Mittal