All things Shopify and commerce
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,
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
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
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024