There seems to be an issue with my pop-up displaying to website visitors even after they have closed it or subscribed previously.
How can I modify the code below to ensure the pop-up is only shown once?
setTimeout(function(){
var newsletterModal = $('#newsletterModal');
if (newsletterModal.length && typeof $.cookie('newsletter_modal') === 'undefined') {
if ($.cookie('age_verified') || !$('#verifyAgeModal').length) {
newsletterModal.foundation('open');
$.cookie('newsletter_modal', true, { path: '/' });
}
else {
verifyAgeModal.on('closed.zf.reveal', function() {
newsletterModal.foundation('open');
$.cookie('newsletter_modal', true, { path: '/' });
});
}
}
}, 20000);
I currently do not use the age verification feature and have kept it in place for potential future use.
Additionally, I am interested in distinguishing between users who have closed the pop-up and those who have subscribed, so that I can re-display the pop-up to non-subscribers after a certain period of time. Is there a way to achieve this distinction?