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:
-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