How to automatically open a popup after N seconds
In this guide, we'll walk you through the steps to set up an automatic popup to appear N-seconds after opening a page.
Our popups function globally, meaning they exist on all pages regardless of whether they're utilized or not.
You might find this guide useful: How to create popups
Once you've created the popup you want, you can then configure it to open on your blog after a specified number of seconds have elapsed.
Copy this code:
Depending on where you want the popup to show, you can add the code:
- In a custom component on the page to show the popup only on that specific page.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chrome9jh9acjiw9_1dojgxz.gif)
- In the "</body> custom HTML code" section to show the popup on every page of your site.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chromeyqppkf0oho_1ueqwhz.png)
- In the "Blog home page </body> code" to show the popup on the blog's homepage.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chromevveqxj7quu_d5ofoy.png)
- In the "Each blog post </body> code" to show the popup on each blog post page.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chromeejnloz2h9t_13nyqsm.png)
In the code replace the popup ID with the ID of your popup (without #)
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/screenshot-2566-04-21-at-09431_s6ir8b.png)
You can locate the popup's ID at the top of the popup editor
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/screenshot-2566-04-21-at-09305_1r8or3z.png)
Castomize the delay after which the popup will appear (in milliseconds)
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/screenshot-2566-04-21-at-09425_1swkzh.png)
Your blog posts will now feature a popup with the delay you've configured.
Our popups function globally, meaning they exist on all pages regardless of whether they're utilized or not.
You might find this guide useful: How to create popups
Once you've created the popup you want, you can then configure it to open on your blog after a specified number of seconds have elapsed.
1. Custom code
Copy this code:
<script>
const time = 3000;
const popupId = "popup-01-00000";
window.onload = () => {
const openAutoPopup = ($popup) => {
$popup.fadeIn(150);
$(".js-custom-popup-mask").fadeIn(200);
const popupExists = $popup.length !== 0;
if (popupExists) {
$("body").addClass("state-fixed-body_popup");
}
}
const $autoPopup = $(`#${popupId}`);
setTimeout(()=>openAutoPopup($autoPopup),time);
}
</script>
2.1 Open popup on the site pages
Depending on where you want the popup to show, you can add the code:
- In a custom component on the page to show the popup only on that specific page.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chrome9jh9acjiw9_1dojgxz.gif)
- In the "</body> custom HTML code" section to show the popup on every page of your site.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chromeyqppkf0oho_1ueqwhz.png)
2.2 Open popup on the blog pages
- In the "Blog home page </body> code" to show the popup on the blog's homepage.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chromevveqxj7quu_d5ofoy.png)
- In the "Each blog post </body> code" to show the popup on each blog post page.
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/chromeejnloz2h9t_13nyqsm.png)
3. Replace the popup ID
In the code replace the popup ID with the ID of your popup (without #)
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/screenshot-2566-04-21-at-09431_s6ir8b.png)
You can locate the popup's ID at the top of the popup editor
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/screenshot-2566-04-21-at-09305_1r8or3z.png)
4. Edit delay
Castomize the delay after which the popup will appear (in milliseconds)
![](https://storage.crisp.chat/users/helpdesk/website/7e782a40c0560c00/screenshot-2566-04-21-at-09425_1swkzh.png)
Done!
Your blog posts will now feature a popup with the delay you've configured.
Updated on: 22/07/2024
Thank you!