Hello Webflow Community,
I’m wondering if anyone knows or could point me in the right direction in order to have a form that is only displayed to new users and hidden for existing, so they don’t see the popup everytime they go back to the page with the form?
Any assistance is greatly appreciated.
Best,
Tony
1 Like
Hi Tony!
To make something like this possible you will need to add some custom code and to interact with localStorage.
First of all, it is need to go to project settings → custom code → footer code
and add custom code like the following:
<script>
if (document.getElementsByClassName('myform') && document.getElementsByClassName('myform')[0]) {
if (Boolean(localStorage.myFormFlag)) {
document.getElementsByClassName('myform')[0].remove();
} else {
localStorage.myFormFlag = true;
}
};
</script>
where myform is the class that is added to element, that needs to be shown to user only once (in my case text My form):
then if users will go to the site they will see it only once while visiting:
This method will work as long as the user is using the same browser on the same machine.
3 Likes
Thank you soo much for the responsive response. Will definitely give this a shot
hey @frontendgirl thanks for the solution here. Is it possible to have the form appear like every 20 days? what should I change to the code to do that? I actually want this to act as an exit pop up, but want it to appear every 20 days, not only once. Thanks!