Streaming live at 10am (PST)

Geo redirect script

Hello!

Please bear with me since I´m by no means a developer :slight_smile: I need to redirect our site to a specific landing page depending on the location of the user. When I first built this site in Muse I used a script that worked like a charm. However, I cannot seem to make it work in Webflow.

The script is as follows:

   <html><head><title></title>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
jQuery.ajax( {
jQuery.ajax({
  url: '//freegeoip.net/json/',
  type: 'POST',
  dataType: 'jsonp',
  success: function(location) {
  // If the visitor is browsing from Spain.
  if (location.country_code === 'ES') {
  // Redirect him to the .
  window.location.href = 'https://elpais.com/';
  }
else
{ return false; }
  }
} );
</script>
</head><body></body></html>

I have tried to paste this code in multiple locations (you see, I´m really far from being a developer), such as the project settings, the home page settings, etc. Both in the head tag and in the body tag. Also tried to embed the code, but nothing worked.

Does anybody know what I am doing wrong? Is this feature not possible in webflow?

Thank you so much!

Hi @SandraBe,
I’ve been struggling a lot with triggering jQuery events in the past, maybe this will help you as well.

Try to put your script within the following script wrapper:

var Webflow = Webflow || [];
Webflow.push(function () {
  // DOMready has fired
  // May now use jQuery and Webflow api
});

Maybe this article will also be helpful for you the walk through, to get a better understanding how to add custom code to your Webflow site:

If this doesn’t fix it for you, try to add your Webflow Share Link, so it becomes easier for the community to offer help:

Hi there!

It’s Ok you are not a developer. Instead of doing coding, there are tools can help. For example, GEO Targetly. It can identify visitors’ physical location by IP using IP geolocation technologies. Its particulate tool, GEO Redirect can auto redirect visitors to different URL webpages based on physical locations, like country, state, city.

The tools are easy to set. No code is necessary.

Hope it helps!

@SandraBe Do you have a working solution for that?