Expand my Community achievements bar.

SOLVED

How can I use the daysSinceLastVisit-plugin within DTM?

Avatar

Level 2

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");
}
s.doPlugins=s_doPlugins;

/* 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"
+"ime(),day=24*60*60*1000,f1,f2,f3,f4,f5;e.setTime(ct+3*365*day);es.s"
+"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"
+"_w(c+'_s',f5,es);}}else{s.c_w(c,ct,e);cval_ss=s.c_r(c+'_s');s.c_w(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;");

1 Accepted Solution

Avatar

Correct answer by
Level 7

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'); }

View solution in original post

3 Replies

Avatar

Correct answer by
Level 7

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'); }

Avatar

Level 10

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