Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How can I use the daysSinceLastVisit-plugin within DTM?

Avatar

Avatar
Validate 1
Level 1
guidov61672237
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
guidov61672237
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
guidov61672237
Level 1

25-07-2016

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
Level 5
andrew_r-GrfLbX
Level 5

Likes

82 likes

Total Posts

133 posts

Correct Reply

36 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 5
andrew_r-GrfLbX
Level 5

Likes

82 likes

Total Posts

133 posts

Correct Reply

36 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
andrew_r-GrfLbX
Level 5

25-07-2016

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)

Avatar

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

93 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

93 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
ParitMittal
Level 10

25-07-2016

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

Avatar

Avatar
Validate 1
Level 1
guidov61672237
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
guidov61672237
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
guidov61672237
Level 1

25-07-2016

Thanks now it works!