Shopify JS object - What does Shopify.country represent

Topic summary

The discussion centers on clarifying what Shopify.country (a property in Shopify’s window object) actually represents, as official documentation is lacking.

Initial Question:

  • User needs to implement a US-only feature and is considering either the Geolocation API or Shopify’s native Shopify.country property.
  • Unclear whether this property reflects the customer’s geolocation or the store’s shipping destinations.

Conflicting Interpretations:

  • One participant claims Shopify.country derives from the customer’s IP address and represents their active location, noting IP-based geolocation has accuracy limitations.
  • Another participant disputes this (as of January 2025), observing that Shopify.country actually reflects the country selected in the Dawn theme’s country/currency selector, not IP-based geolocation—since the value changes when users manually select a different locale.

Current Status:

  • The exact behavior of Shopify.country remains unresolved with contradictory explanations.
  • The Geolocation API is suggested as an alternative for more precise location detection if needed.
Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Hi,

I’m trying to work on a feature on a store for US based customers only.

What seem to be my 2 options is the Geolocation API or Shopify’s native window object that has several properties.

One of them is Shopify.country with returns a string representing a country.

I can’t find any online documentation explaining this in detail - but what is this exactly? Is this returning the users current active location, or where the stores ships to?

The Shopify.country property in Shopify’s window object represents the country of the customer’s current active location. It is derived from the customer’s IP address and is used to determine the country for various functionalities, such as displaying relevant content or applying specific rules based on the customer’s location.

It’s important to note that Shopify.country does not directly indicate the countries where the store ships to or restricts shipping. Instead, it provides information about the customer’s location, which can be used to customize the shopping experience based on their country.

If you need to implement features specific to US-based customers only, you can utilize the Shopify.country property to detect the customer’s location and conditionally display or enable certain functionalities tailored for US customers. Keep in mind that IP-based geolocation is not always 100% accurate and may have some limitations or discrepancies.

Additionally, you may also consider using the Geolocation API to achieve more precise geolocation detection and customization if needed. The Geolocation API provides more detailed information about the user’s location, such as latitude, longitude, and address, which can be beneficial for implementing region-specific features or restrictions.

I’m not sure this is entirely accurate (or is not accurate as of 1/10/2025). window.Shopify.country is returning the country specified in the country selector in the Dawn theme. If it were based on IP address, it wouldn’t change when a new country/currency is selected. So it is either a) not based on IP address, or b) selecting a specific locale overrides the geo location.