clemensw
7 years agoGuide
Prompt modal after x visits and y seconds (as used in "Value Analytics")
Dear community,
is it possible to use the conditions from “Value Analytics” (e.g. “Prompt users with survey after this many visits”, or “after this many seconds” or “after his many days”) in FreeMarker?
Are there other ways to set the number of visits and the visit duration as conditions in FreeMarker?
Use case:
We want to prompt a custom modal (not the “Value Analytics” modal) after the x visits and y seconds
Thank you!
best regards, Clemens
It's all about the cookies functions(getCookie and setCookie). You need to set the cookie for the user's every visit and then you can show the pop up on the third visit. You can use the given snippet to get on the track.
var date = new Date(); date.setTime(date.getTime() + (90 * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); /* Function To Get Cookie Value */ window.getCookie = function (name) { var value = "; " + document.cookie; var parts = value.split("; " + name + "="); if (parts.length == 2) return parts.pop().split(";").shift(); } var visit_cookie = getCookie('visit_count'); var third_visit = false; if(visit_cookie == null){ document.cookie = "visit_count=0"+ expires + "; path=/"; } visit_cookie = getCookie('visit_count'); if(parseInt(visit_cookie) >= 2){ third_visit = true; } else{ visit_cookie = parseInt(visit_cookie) + 1; third_visit = false; document.cookie = "visit_count="+visit_cookie+ expires + "; path=/"; } /* Hide Popup If Survey is Taken Or User Is not Interested or It is not third time visit */ var survey_cookie = getCookie('survey_modal'); //console.log("Pop Up Running"); setTimeout(function(){ if(third_visit){ $('.survey_modal').show(); } }, 90000);