How can I display country-specific content on my website?

How can I display country-specific content on my website?

savdbroek
Visitor
3 0 0

Hi there,

 

I'm trying to figure how to show specific content to traffic from certain countries.

I found this page, however it doesn't seem to fully work.

 

This piece of code is a test that I used to check if the idea will work.

It should show "Test NL" to a visitor from the Netherlands and Test Other, from any other country.

 

However, it shows "Test NL" to everyone. I've also tried adding the following line before "else".

{% elsif localization.country.iso_code == 'BE' %}

To show specific content to people from belgium, this also ended up showing "Test NL".

 

Am I doing something wrong?

 

Thank you for reading!

 

Kind regards,

 

Sander

 

 

 

{% if localization.country.iso_code == 'NL' %}
Test NL
{%- else -%}
Test Other
{% endif %}

 

 

Replies 2 (2)

Mac
Shopify Staff
1702 178 298

Hi, @savdbroek

Thanks for reaching out in our Community forums and for sharing your concern, I’d be happy to provide some alternative methods for you to consider. 

 

I understand that you are looking to implement a solution that will filter the content on your site on a country to country basis. This is completely possible through code adjustments and third party apps. If you would like some hands on assistance, contacting Shopify Experts would be a great idea. This is a marketplace that connects you to professionals in a variety of fields related to your e-commerce business. Doing so will allow you to outline your exact requirements and specifications to set this up on your store. If you would like to know more about finding the right Expert, please click here.

 

You can also look to introduce an app that will allow you to set country specific content, products, collections, locations, and currency without requiring multiple stores and redirects. So, if you’re wanting a customer from a certain country would only be able to view a specific blog that is available to their region. You can check out an app called Advanced Store Localization which may offer the functionalities necessary for you to accomplish this, or browse our other Geolocation apps that offer similar functionalities.

 

I’d love to know more about your business! What type of products are you selling and how are you planning to market them to multiple regions? 

Mac | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Kabelbinders
Visitor
1 0 0

I know this is an old post, but I thought I'd give my input on the topic as the response you got wasn't very helpful from the experts. And as I've just had the same issue, I found the code you provided to work just fine.

 

I think what your issue may have been, is that the country wasn't really selected - therefore the generic content was shown? Or it's not necessarily a 'visitor of the country' that gets shown the content, it's the country you have actually selected that you're ordering to.

 

 

Meaning if you tested that code and had a ?country=NL in your URL, or manually changed/forced the country selection to be Netherlands - it'd show. But this is only from my understanding if the country selection is a part of a market that can genuinely be selected. The ?country=XX / manual selection won't work on my Shopify store for countries that are not in the market. Hope that makes sense!

 

 

e.g. this works for me just fine:

        {% if localization.country.iso_code == 'NL' %}

  // NL CONTENT

        {% elsif localization.country.iso_code == 'DE' %}

  // DE CONTENT

{% else %}

GENERIC CONTENT

{% endif %}