What's your biggest current challenge? Have your say in Community Polls along the right column.

How to know which country subscribers are from using Shopify markets?

How to know which country subscribers are from using Shopify markets?

AliceNilfisk
Shopify Partner
2 0 0

Hi,

I am using the typical 'sign up to our newsletter' pop up on our website but I noticed that there is no country assigned to the new subscribers in Shopify.

 

I am using Shopify markets and want to offer a 10% off discount code in an email to new subscribers. But I need to know which country they come from so I can share the email in the right language. We do not ask subscribers to tell us which country they are from, but we should know this information as they are on a local version of the site. 

 

For example, people signing up from shop.nilfisk.com/de-de page are from Germany, and anyone from shop.nilfisk.com/fr-fr is from France. 

 

Is there some way to feed this country information into the contact in the backend?

 

Many thanks,

Reply 1 (1)

rajweb
Shopify Partner
396 39 52

Hey @AliceNilfisk ,

To capture a subscriber's country automatically in Shopify, you could modify your newsletter sign-up form to include this information based on the site version they’re visiting. Since you’re using Shopify Markets, the URL structure with locale information (/de-de for Germany, /fr-fr for France) can be utilized to determine the subscriber’s location. Here’s a way to achieve it:

Step 1. Update the Form Code:

Add a hidden field in your newsletter sign-up form to capture the country code based on the URL. Here’s how:

-Locate your newsletter form code (usually found in theme.liquid, footer.liquid, or a dedicated newsletter section file).

-Add a hidden input field to the form to capture the country:

 

<form method="POST" action="/contact#newsletter">
  <!-- Existing form fields -->
  <input type="hidden" name="Country" id="newsletter-country" value="">
  <input type="email" name="Email" placeholder="Your email">
  <button type="submit">Subscribe</button>
</form>

 

-Set the hidden field value dynamically using JavaScript to detect the URL locale and assign the appropriate country code

 

Step 2. Use JavaScript to Populate the Country Field:
Add a JavaScript snippet to set the value of the hidden Country input based on the URL:
 

 

document.addEventListener("DOMContentLoaded", function() {
  const countryField = document.getElementById("newsletter-country");
  const path = window.location.pathname;

  if (path.includes('/de-de')) {
    countryField.value = "Germany";
  } else if (path.includes('/fr-fr')) {
    countryField.value = "France";
  } 
  // Add other locales as needed
});

 

This code checks the page path and fills in the Country field with the correct value. For new subscribers, Shopify will save this information in the Notes section of each subscriber's profile, so you can later segment by country.

Steps 3. Automate the Welcome Email with Localization:

Once you’re collecting country information, set up an automated workflow in Shopify Email (or your email marketing app) that sends a localized email based on each subscriber’s country. You can also set conditions for each locale to ensure they receive the 10% discount in their local language.

 

If I was able to help you, please don't forget to Like and mark it as the Solution!
If you’re looking for expert help with customization or coding, I’d be delighted to support you. Please don’t hesitate to reach out via the email in my signature below—I’m here to help bring your vision to life!

Best Regard,
Rajat Sharma

 

-Need a Shopify developer?
https://rajatweb.dev/
Email: rajat.shopify@gmail.com