Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
Is their a way to display a message or a banner in header of the storefront based on customer location?
example: if visitor located in UK, display a special message or a banner at header (something for shipping)
Thanks in advance
Solved! Go to the solution
This is an accepted solution.
Hi @BM136,
You can contact ipregistry directly for further assistance: https://ipregistry.co/
Because I used their API and everything works fine. It will be the best way if you don't install the app.
If it helped you solve your issue, please mark it as a solution. Thank you and good luck.
Hi @BM136,
Please go to header.liquid file and add code:
<div class="header-message" id="MessageCountry">
</div>
<script>
fetch('https://api.ipregistry.co/?key=tryout')
.then(function (response) {
return response.json();
})
.then(function (payload) {
switch(payload.location.country.code) {
case 'UK':
document.getElementById('MessageCountry').innerHTML = 'Message';
break;
case 'FR':
document.getElementById('MessageCountry').innerHTML = 'Message';
break;
default:
document.getElementById('MessageCountry').innerHTML = 'Message';
}
});
</script>
You can display Message with text or html you want.
Hope it helps!
Hi,
Thanks, it is useful. but it works for about 2 times only then stop working
This is an accepted solution.
Hi @BM136,
You can contact ipregistry directly for further assistance: https://ipregistry.co/
Because I used their API and everything works fine. It will be the best way if you don't install the app.
If it helped you solve your issue, please mark it as a solution. Thank you and good luck.
Hey. @BM136 Great question.
I have actually only heard of one app that allows you to personalize your homepage and the content it displays depending on the visitor that is viewing your storefront. The app is called DataCue. They offer a 14-day free trial and then plans start at $9.99/month.
Note: I do not have experience using this app so I can't speak to how it functions. However, they do have a handful of reviews on their page that you can always check out.
Dirk | 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
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