Shopify Tutorials

How to Show Content Based on Customers’ Locations on Shopify?

Hello, Hola, Bonjour, and Namaste, Shopify merchants. šŸ¤—

Welcome to MageComp Shopify tutorials. šŸ¤©

Today, we are here with one of the most awaited and demanded Shopify tutorials: how to show Shopify website content based on the customersā€™/visitorsā€™ location.

Shopify merchants that have an audience base spread all around the world face one common query ā€“ showing their website in the native language of the visitor or the customer. If you also have the same query, by the end of this tutorial, you will have got your answer. Keep Reading!!!

What Does Showing Shopify Website Content Based on Customersā€™ Locations Mean?

Showing website content based on customersā€™ location, often referred to as ā€œgeotargetingā€ or ā€œgeo-targeted content,ā€ is a technique used by websites and online platforms to customize the content that visitors see based on their geographic location. This customization is done by detecting the userā€™s IP address, GPS coordinates, or other location data and then delivering content that is relevant to or specific to that particular region or country.

What are the Benefits of Showing Website Content in Customersā€™ Local Language?

Showing website content based on customersā€™ location, often referred to as geotargeting, offers several benefits that can enhance the user experience and improve the effectiveness of your website. Here are some of the key advantages:

Personalized shopping experience

Geotargeting allows you to deliver a personalized experience to visitors. When users see content relevant to their location, they are more likely to engage with your website, leading to increased user satisfaction and a higher likelihood of conversion.

Relevancy

Tailoring content to a userā€™s location makes it more relevant. For example, showing local news, events, or promotions can capture the userā€™s attention and encourage them to explore further.

Enhanced user experience

Geotargeting helps in providing a seamless and relevant user experience. Visitors donā€™t have to sift through irrelevant content or struggle to find local information.

Benefits local SEO

If you have a physical presence or operate in specific geographic areas, geotargeting can help with local search engine optimization (SEO). It can improve your websiteā€™s visibility in local search results, increasing the likelihood of attracting local customers.

Boosted conversion rate

When users see products, services, or promotions relevant to their location, they are more likely to convert. This can lead to higher sales and engagement rates.

Better advertising opportunity

If you run advertising campaigns on your website, geotargeting can help you display location-specific ads, which can be more effective and lead to a higher click-through rate.

Competitive Benefit

Providing a location-specific experience can set you apart from competitors who do not utilize geotargeting, giving you a competitive advantage.

Show Website Content Based on Customersā€™ Location

Step 1 ā€“Ā 

Log in to your Shopify account and navigate to

Shopify admin panel ā†’ Settings ā†’ Checkout

Step 2 ā€“

Scroll down to the Checkout tags page until you reach the order status section. Just below the order status page, you will find Additional scripts where you have to enter the code that will help your website show location-based content to your customers.

Step 3 ā€“

Paste the following code into this field. šŸ‘‡

{% if checkout.shipping_address.country_code == 'US' and checkout.shipping_address.province_code == 'NY' %}
<script type="text/javascript">
  var customMessage = document.createElement("div");
  customMessage.innerHTML = '<div class="section" style="padding-top: 3em"><div class="content-box"><div class="content-box__row"><p class="os-step__description">TYPE YOUR CUSTOM MESSAGE HERE.</p></div></div></div>';
  console.log(document.querySelector("[data-order-summary-section=payment-lines]"));
  document.querySelector("[data-order-summary-section=payment-lines]").before(customMessage);
</script>
{% endif %}

In this step, you can edit the code according to your location preference. Just type the specific country or region codes in the Liquid code {% if %}.

In this tutorial code, we have chosen the USA as the country and New York as the state/province name.

For example, if you want to choose Canada as your country, you should put CA in the code like,Ā 

checkout.shipping_address.country_code == 'CA'

You can change the country code in this Liquid code according to your requirements.

Similarly, if you want to choose a particular province of a country, e.g., Manitoba, Canada.

For this, you should add the following code with the province code of Manitoba,

checkout.shipping_address.province_code == 'MB'

So, the entire code will be like this šŸ‘‡

{% if checkout.shipping_address.country_code == 'CA' and checkout.shipping_address.province_code == 'MB' %}

Step 5 ā€“

Before moving further and making your changes live, place a test order, test the changes made and ensure you have pasted the code correctly.

Once you are done, Save your changes and done.Ā 

Over to You

This is it. Yes, it was a bit tricky and had coding in it, but you just need to copy this code and paste it into your Shopify store backend, and you are good to go.

Hope you found this tutorial useful, and if you still have any queries or things did not go as per this tutorial, feel free to contact us and hire Shopify developers to make things right.

Happy Shopifying!!!

Click to rate this post!
[Total: 0 Average: 0]
Gaurav Jain

Gaurav Jain is Co-Founder and Adobe Certified Expert-Magento Commerce Business Practitioner. Being Computer EngineeršŸ‘Øā€šŸ’» and possessing Extensive Marketing skills he handles all kinds of customer Queries and his HappyšŸ˜€ & HelpingšŸ™ Nature makes customer's day Delightful. When he isnā€™t working, youā€™ll find Gaurav Reading on BooksšŸ“– or TravelingšŸš—. Also, he is Speaker at Magento Meetups.

Recent Posts

Magento 2: How To Call JS on the Checkout Page?

Hello Magento mates, Today we will learn to add a call JS on the checkout…

2 days ago

Boost Your SEM Game: Unveiling the Top 10 Tools for Marketers in 2024

Business survival in todayā€™s digital world has become extremely difficult. Using traditional marketing techniques is…

3 days ago

Five Essential Payroll Compliance Tips for eCommerce Startups

Are you setting up a payroll system for your eCommerce startup? Ensuring compliance with myriad…

4 days ago

Optimizing Laravel Blade: Unlocking Advanced Fetcher Techniques

In the expansive universe of Laravel development, Blade serves as the stellar templating engine, propelling…

4 days ago

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

6 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

1 week ago