Integrate your selector
Please don't follow this article if you have multiple stores to redirect with Orbe. Your selector should be any one created by the Orbe app. Follow this article: Geolocation Button
In our app Orbe, we have an app embed called "Market Selector" that allows any Shopify merchant to add and customize a country and language selector in the footer of any Shopify Theme. These selectors use the Orbe technology.
However, some merchants would like to use their native Shopify theme country and language selector with Orbe because they want its style and UX in their theme. They can work with a developer to synchronize this theme selector with Orbe for that case.
Tutorial
This tutorial provides a straightforward and effective method for integrating a country selector with Orbe, ensuring a seamless user experience.
1. Retrieve the store domain
First, ensure we correctly set cookies across your Shopify store by capturing the domain.
This can be achieved using Orbe's getCountryDomain function. If this function does not provide a result, we'll use window.location.hostname as a reliable fallback.
let shopDomain = (typeof orbito !== 'undefined' && orbito.getCountryDomain) ? (orbito.getCountryDomain() || window.location.hostname.replace(/^www\./, '')) : window.location.hostname.replace(/^www\./, '');2. Customize the onItemClick event handler
Locate the function in your Shopify theme that triggers when a user selects a country or language. This function usually handles the event and submits the form in the last step.
Here you have an example of the code for the selector of the official Shopify documentation:
onItemClick(event) {
event.preventDefault();
const form = this.querySelector('form');
this.elements.input.value = event.currentTarget.dataset.value;
if (form) form.submit();
}For each scenario, it is super important that you update this:
Country change: Update the cookie
mdApp_countryCodeDomainand indicate in a URL parameter this update to Shopify Markets. This is only necessary for country change as you may set up a different subdomain or domain for a market, and you will move these preferences throughout the URL parameter to Shopify Markets.Language change: Update the cookie
mdApp_showRecommendationLang.
Here is the code improvement based on the above example:
Real example
Here is an example of how the entire code might look, based on the JavaScript for the official Shopify country selector documentation:
Last updated
Was this helpful?