I’m working on implementing tracking for a multi-market Shopify store (thehappybed.com) that uses Shopify Markets for international sales across multiple European countries (NL, BE, FR, etc.).
Current situation:
Each market corresponds to a specific country
Different marketing pixels need to be fired based on the market/country
Currently using custom JavaScript to determine the market based on URL patterns and country data
This solution is proving unreliable and difficult to maintain
Question: Is there a way to access the current Shopify Market directly through the data layer?
Ideally, I’d like to:
Have the market identifier (e.g., ‘nl’, ‘be’, ‘fr’) available in the data layer
Use this for consistent market-specific pixel firing
Avoid relying on URL parsing or custom JavaScript solutions
@Jos_Meiling handling markets is a feature we’re discussing. Market data is not exposed in the pixel_api so it’s not as straightforward as we’d want it.
That being said, I don’t understand why you need custom JS for this. Native URL (or Page Path) variable + native Lookup Table is all you need to handle destinations dynamically.
Great, that you are discussing this. Hopefully, you find a proper solution to incorporate it.
Regarding the custom JS, on regular pages you can extract it from the url (f.e. https://thehappybed.com/da-dk). In this this case the market is ‘dk’. The fallback market is the netherlands (no /nl-nl included). Starting from the checkout the market is no longer in the url. From that point on I take the user country. Additionally, the same container is used on a different domain for UK:happtduvet.co.uk (uk market), which is using the same theme.
If you have any suggestions to make it more robust, please reach out
I think the only option here is to write the market data to session storage for example to make it available to the checkout and from there determine where to send events.
Unfortunately, as Dan wrote, there is currently no endpoint in the Pixel API to easily and correctly define a market because of this we also can’t implement a convenient handling of this on the Stape app side.