Skip to main content

I'm trying to create a pop-up that is going to be triggered to any user that is coming from outside the US. I've created a pop-up with the custom trigger and also the code to be added on the theme.liquid just before the </body> . However I can't make it work, any ideas?

 

<script type="text/javascript">
  function getGeolocation(callback) {
    const userCountryCode = 'US';
    callback(userCountryCode);
  }
  function openPopUpBasedOnGeolocation(userCountryCode) {
  
    if (userCountryCode !== 'US') {
   
      window._klOnsite = window._klOnsite || d];
      window._klOnsite.push(n'openForm', 'FORM_ID']);
    }
  }

 openPopUpBasedOnGeolocation
  getGeolocation(function (userCountryCode) {
    openPopUpBasedOnGeolocation(userCountryCode);
  });
</script>
 

Hey @paulanoba! You’ll get much more insightful answers on anything to do with custom code in our Developer Group. I’ve moved this thread over there for you! :) 


Hi @paulanoba!

When you say that you can’t make it work, would you mind explaining a little more about what is/is not happening? Is the form appearing and not collecting the correct information, or is the form not appearing at all?

 

Cheers,

Brian


Reply