Question
How can I create a pop-up of the messaging widget, immediately after the website loads?
Answer
After having installed messaging on your website, add the following JavaScript code near your body
tag, after the widget snippet:
<script type="text/javascript">
zE(function(){
zE('messenger', 'open');
});
</script>
If you want the chat to pop up after a certain amount of time, post page load, wrap the zE function within a setTimeouts
method using the following script:
<script type="text/javascript">
window.setTimeout(function() {
zE(function() {
zE('messenger', 'open');
});
// You can add more APIs on this line, if needed
}, 10000); // Set delay in milliseconds (10 seconds = 10000ms)
</script>
If you want to set a delay, then in the above script, replace 10000
with the number of milliseconds of your choice. For example, 5000
for a 5-second delay.
To you test this functionality:
- Verify that the widget loads without interfering with the user experience.
- The timing of the pop-up aligns with the user interaction.
- Ensure all links and functions in the messaging window should operate as expected.
Note: If you use the Web Widget (Classic), achieve comparable results by following the steps outlined in this article: How can I customize the widget to automatically open when the page loads?
For more information, see Core messaging Web Widget API.