Kairike Posted November 15 Share Posted November 15 Hello, Is it possible to redirect Squarespace pages with the following code? I can't seem to get it to work. I have tried entering the code in the page header section. I'm trying to redirect to a language specific page within the same site, not a separate site/domain. Thank you! K. <script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script> <script> if(geoplugin_countryCode() != 'EE'){ if(geoplugin_countryCode() == 'GB'){ location.href = "https://www.wizardscreeklabradors.com/en/home/"; }else{ location.href = "https://www.wizardscreeklabradors.com/en/home/"; } } </script> Beyondspace 1 Link to comment
Solution Beyondspace Posted November 15 Solution Share Posted November 15 1 hour ago, Kairike said: Hello, Is it possible to redirect Squarespace pages with the following code? I can't seem to get it to work. I have tried entering the code in the page header section. I'm trying to redirect to a language specific page within the same site, not a separate site/domain. Thank you! K. <script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script> <script> if(geoplugin_countryCode() != 'EE'){ if(geoplugin_countryCode() == 'GB'){ location.href = "https://www.wizardscreeklabradors.com/en/home/"; }else{ location.href = "https://www.wizardscreeklabradors.com/en/home/"; } } </script> The problem is the script is called using HTTP protocol, while your Squarespace page is served as HTTPS, you will see this error in console indicated that browser not allow mixed-content, therefore the geoplugin_countryCode method is not usable To use the HTTPS protocol you need to buy SSL key subscription from them at 24 EUR per year https://www.geoplugin.com/premium Kairike 1 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Kairike Posted November 15 Author Share Posted November 15 6 hours ago, Beyondspace said: The problem is the script is called using HTTP protocol, while your Squarespace page is served as HTTPS, you will see this error in console indicated that browser not allow mixed-content, therefore the geoplugin_countryCode method is not usable To use the HTTPS protocol you need to buy SSL key subscription from them at 24 EUR per year https://www.geoplugin.com/premium Ah, great, thank you! I wouldn't have figured it out myself. Maybe that is why the example I found to write my code writes the location.href without HTTP or HTTPS (see below) but I tried that too, didn't work for me. 24€ a year is not too bad if that would guarantee that it works. Alternatives like Geo Targetly are way more expensive. <script> if(geoplugin_countryCode() != 'US'){ if(geoplugin_countryCode() == 'CA'){ location.href = "//www.domain.ca"; }else{ location.href = "//www.domain.com"; } } </script> Beyondspace 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment