Spy on Your Competitors - Extended Free Trial!  GO!
How to Show Content Based on Customer’s Locations on Shopify

How to Show Content Based on Customer’s Locations on Shopify

Last modified: December 2, 2021

FAQ
Shopify Trial

When you sell to different areas of the world, or even a country, you might need to show different content. For instance, you might have different contact details for those who are in the UK to those in the US.

Having a long list of content that’s applicable to everyone is messy. And it isn’t always good for the customer journey. You might also want to show customers specific content based on the shipping method/whether they’re collecting the item in the store.

So, here is a set of step-by-step instructions to help you.

Recommended: The Top 10 Shopify Geolocation Apps

# Name Image
Shopify
Shopify
More Info
1
EasyLocation ‑ GeoIP redirects
EasyLocation ‑ GeoIP redirects
More Info
2
Geolocation
Geolocation
More Info
3
Geolocation Redirect
Geolocation Redirect
More Info
4
GeoIP Country Redirect/Blocker
GeoIP Country Redirect/Blocker
More Info
5
Shipping Rates Calculator Plus
Shipping Rates Calculator Plus
More Info
6
Currency Converter Ultimate
Currency Converter Ultimate
More Info
7
Product Inventory Information
Product Inventory Information
More Info
8
Geolocation Redirects
Geolocation Redirects
More Info
9
Geolocation Express Redirect
Geolocation Express Redirect
More Info
10
Prime Visitor Redirect & Block
Prime Visitor Redirect & Block
More Info
Show More
Click here for more information about The Top 10 Shopify Geolocation Apps.

Step 1 – Login

Login to your Shopify website using your user credentials.

Step 2 – Checkout

From within the admin page on Shopify, click on ‘Settings’, which is at the bottom of the admin page as you login. There is then an option labeled ‘Checkout’.

Step 3 – Additional Scripts

In the ‘Order processing’ section there are four different sections. Find the ‘Additional’ scripts option, which is last on the list and then select it.

Step 4 – Showing The Message To Some In A Specific Country

Then you need to copy the code below and paste it into the text box within the ‘Additional Scripts’.

{% 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">ADD YOUR 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 %}

This message will display those in the United States and New York. You can then make the changes. Be sure that you’re using abbreviations. You can get the postal abbreviation of any US state using the list provided by UPS.

To add more than one state or area to your custom code, you can add the following code:

and checkout.shipping_address.province_code == 'XX'

Where XX is the abbreviation for the state. Remember to check the abbreviation is correct. You can also change the country. And to not specify a specific state, you can do so by removing that part of the code.

Step 5 – Save

When you’ve made the changes that you want to make, click on the ‘Save’ button. This should now show your message based on the location of the customer.

Step 6 – Test

Be sure to test your new code on the website. There are numerous errors that can be accidentally made when entering in the code. You might need to use a VPN to show the messages for different countries/states.

You can test your new code by placing a test order.

Final Word: How to Show Content Based on Customer’s Locations on Shopify

This very easy method allows you to show content that is based on the customer’s location, wherever they are. While the example above is using the US and New York, these locations can be changed to wherever you would like them to be.

This allows you to put out warnings to customers in areas where there might be delays to some deliveries due to natural disasters or certain processes outside of your control. It might also be a good way to upsell or cross sell to those in certain areas.

If you need more help customizing your checkout, you can look at this app here.

Recap:
Read More
Got Something To Say?

Your email address will not be published. Required fields are marked *

Free Trial