Hello,
We have DTM installed on a SPA platform. The problem I have is that the days since last visit plugin does not seems to work because of the return false function we use to supress the initial page load beacon.
This is the customer code we use on tool level:
return false
s.abort = true;
s.usePlugins=true
s.doPlugins=function(s) {
/* Add calls to plugins here */
s.prop45 = s.getDaysSinceLastVisit('dslv');
s.eVar45 = 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"
+"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;");
Regards,
Guido
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Guidov,
The issue is that you are using both return false & s.abort=true in your code However the purpose of both is the same and importantly the s.abort=true or return false should be the last line of your customize code and execute the code by selecting the radio button "After UI settings takes place" Hence your code should look like below.
We have also tested the same at our end and it is working .
s.usePlugins=true s.doPlugins=function(s) { /* Add calls to plugins here */ s.prop45 = s.getDaysSinceLastVisit('dslv'); s.eVar45 = 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" +"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;"); s.abort = true;
Thanks & Regards
Parit Mittal
Views
Replies
Total Likes
Hi Guido ,
Can you please add return false; after the plugin code i.e. return false should generally be last line in a piece of custom code and check if this works .
Thanks & Regards
Parit Mittal
Views
Replies
Total Likes
Hi Parit,
I followed your instructions, but now the beacon is not being suppressed. Do you have another solution?
Regards,
Guido
Views
Replies
Total Likes
Hi Guidov,
The issue is that you are using both return false & s.abort=true in your code However the purpose of both is the same and importantly the s.abort=true or return false should be the last line of your customize code and execute the code by selecting the radio button "After UI settings takes place" Hence your code should look like below.
We have also tested the same at our end and it is working .
s.usePlugins=true s.doPlugins=function(s) { /* Add calls to plugins here */ s.prop45 = s.getDaysSinceLastVisit('dslv'); s.eVar45 = 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" +"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;"); s.abort = true;
Thanks & Regards
Parit Mittal
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies