Lightbox based on Location

Hi,

I would like to trigger a lightbox based on the location the visitor has. How would I do this with Wix Code?

/Mikael

Hi,

In each page site you have an onReady() function at your code page.
In this function you write code that you wish to run before the user starts interacting with your page.
As a result, in the pages that you wish the lightbox will be pop up, add an openLightbox() functions.
Here you can read more about this function.

import wixWindow from 'wix-window';

$w.onReady(function () {
wixWindow.openLightbox("LightboxName")
  .then( () => {
  } );

});

Best,
Sapir

Thank you for that. Now, how would I code it to open if a visitor is visiting from e.g. Sweden?

Hi,

View this example about Using the Places API from Google Maps services
https://www.wix.com/code/home/forum/wix-tips-and-updates/example-using-the-places-api-from-google-maps-services.

Best,
Sapir