All things Shopify and commerce
We are looking to redirect users from our Shopify website to a third-party non-Shopify website based on their location, using the appropriate domain for that location.
As an example:
We saw third party apps that could somehow do this, but will these work from Shopify to non Shopify website?
Hi,
Geolocation API with JavaScript to Shopify theme (theme.liquid) may help
Example of javascript code
<script>
// Replace with your chosen geolocation API endpoint and API key
const geoApiUrl = 'https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY';
fetch(geoApiUrl)
.then(response => response.json())
.then(data => {
const userCountry = data.country_code2; // Get the country code from the response
if (userCountry === 'AU') {
window.location.href = 'https://www.yyyyy.com.au';
} else if (userCountry === 'NZ') {
window.location.href = 'https://www.yyyyy.com.nz';
}
// Add more conditions for other countries as needed
})
.catch(error => {
console.error('Error fetching the geolocation data:', error);
});
</script>
Hope this will help or if you still need help you can contact us
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025