Jump to content

Geoplugin redirection

Go to solution Solved by Beyondspace,

Recommended Posts

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>

 

Link to comment
  • Solution
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

image.thumb.png.4a6359463f40059ebcc66da2305c8315.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 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
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

image.thumb.png.4a6359463f40059ebcc66da2305c8315.png

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>

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.