One time Pop-up + timer

Hello guys :slight_smile:

I was wondering if it was possible to create a pop-up (lightbox) that appears only one time per customer AND only after a certain amouth of time passed on a page (like 15 seconds). I would be very happy if the pop-up would :

  • Appear after 15 seconds the customer is in my shop page
  • Appear one time per customer (if it could reset every month it would be awesome)
  • Disapear automatically after the customer as subscribe (the customer doesn’t have to click on the X to close it).

I already know how to make a one-time pop-up on a page but I’m not sure how to combine all those things together. In my opinion it would create the perfect subscribe pop-up ever !

Thank you for your help (sorry for my english I’m way better in French )

Hi Marie,

See my comments below

- Appear after 15 seconds the customer is in my shop page:
To execute the function after 15 seconds, use setTimeout()

- Appear one time per customer (if it could reset every month it would be awesome)
You can use wix-storage setLocal to save the last time a popup was displayed.
Then read it every time somebody visits a relevant page and check if its already been more than a month.

- Disapear automatically after the customer as subscribe (the customer doesn’t have to click on the X to close it).

At the moment there is no integration between the subscribers system and Wix code.
You can place the Get Subscribers element inside the lightbox however you will not be able to know if there’s was an interaction or not.

If you do create your own custom subscriber form you will be able to know if an interaction happened, however you will have to then add the subscriber email address by hand since there is no integration.

Hope this helps.
Ido

Wow thank you so much !!

Hello again,

I’m sorry but do you have an example of a code for settimeout ? Mine just dont work. Do I have to write it after my code for my one-time pop up on my « page code » ?
Thanks !!

Hi Marie,
The following line will write ‘Hello’ to the console after 3000 ms.

setTimeout(function(){ console.log("Hello"); }, 3000);

Ok thank but do you have an exemple that would make a lightbox appear 15 seconds after the customer is in my shop page ?

Thanks !!

try

import window from ‘wix-window’;
setTimeout(function(){ window.openLightbox(‘PutYouLightboxNameHere’); }, 15000);

Thanks but it doesn’t work :confused:

Mary 214

This should do it:
Put this code on your page where you want the Lightbox to open (or in Site):

import window from 'wix-window';
$w.onReady(function () {
  setTimeout(function(){
    if (!local.getItem("alreadySeenLightbox")) {
      wixWindow.openLightbox("subscribeLightbox");
      local.setItem("alreadySeenLightbox", "yes");
    };
  }, 15000); 
});

And put this in your Lighbox’s code:

$w("#subscribeButton").onClick( (event) => {
  wixWindow.lightbox.close();
}

Your Lightbox’s ID must be subscribeLightbox and your button’s ID must be subscribeButton

Hope this helps!

Hi, has anyone recently done the timeout feature with a lightbox popup and gotten it to delay by X amount of time and still only popup once per visitor after putting in the local session code? I can’t figure out how to put it on a delay now that I’ve done that. Thank you!

Hi there,

Anyone know how to make it reset after 1 month?
I’ve gotten the setTimeout command to work and the clear the local storage after sort time periods but you have to keep the webpage open and therefore it won’t work for one month.

Thanks