Modal under condition

Good morning to all,

I would like to know if it’s possible to display a modal according to the website a user comes from. For example, a user comes from google: the modal is not displayed. The user comes from Facebook, it is displayed.
Thank you for your help

Hey @Pat , there is a way you can do that, it may not work all the time…

Place this in the page footer (it needs to be placed after the modal).

Replace my-modal for the ID of your modal.

<script>	 
if (document.referrer.split('/')[2] === 'facebook.com') { 
    // do something eg.. open modal
   $("#my-modal").modal()
} 
</script>
2 Likes

Many Thanks

Hey @PeteSharp
Is it possible to display a modal based on a date only?
Here in Thailand, it is common to have a pop-up on royal holidays.
Thanks.

Yes you could do that.

1 Like

This post made me think… Is it possible for your Modal recognize different countries and have a Modal specifically for that Country? Not that I would ever use it but curious if it could be done.

There are ways to get the country. These days privacy matters more and more. Also with the use of VPNs and more secure browsers, it makes it pointless. As they often dont work.