9 min read Store Locator
Store Locator HTML Code: What It Takes to Build One
A plain breakdown of what store locator HTML code actually contains, how geolocation and product search fit in, and where you paste it on each platform.
Store locator HTML code is a small embed: a container element plus a script tag that loads a map, reads your location data, and sorts the results by distance. The map provider, the geolocation method, and whether shoppers can search by product are separate choices layered on top of that base.
A merchant rarely writes this code by hand. A plugin, app, or SaaS widget usually generates it and hands you one snippet to paste. Knowing what it contains still helps, because it shows what you can customize.
What the Snippet Actually Contains
Three parts make a working store locator. A map library renders tiles and pins, using Google Maps, Mapbox, Leaflet with OpenStreetMap tiles, or a vendor's own vector renderer.
A location data source feeds it addresses and coordinates, as a static JSON array, a CSV turned into JSON, or a live API call. A distance function, almost always the haversine formula on latitude and longitude, sorts locations by how far they sit from the shopper.
Geolocation Needs a Fallback, Not Just a Prompt
A locator can find the shopper two ways. Browser geolocation asks permission and returns a precise device position, while an IP-based estimate skips the prompt and returns a city-level guess instead.
Shoppers who decline that prompt still expect a working near-me search on mobile. A practical fix is to fall back to an IP-based estimate, or a manual address search, when the shopper declines the prompt.
Where You Actually Paste the Code, by Platform
On Shopify, merchants rarely paste HTML. Theme architecture renders third-party content through app blocks, which let an app add content to a theme without editing theme code, so a locator installs as a block instead of a copied snippet.
WordPress works through its Block Editor instead: a shortcode dropped into any block renders the locator on that page, no HTML required. Our WordPress guide walks through one plugin's full setup.
Squarespace's Code Block is the documented place for custom HTML, though JavaScript and iframes inside it need the Core plan or higher. Wix instead offers an Embed HTML element for pasting a snippet, or a locator app from its App Market; our Wix guide covers that flow.
Many other builders, Webflow, BigCommerce, and Elementor included, ship a similar embed or HTML element for the same purpose.
A Pre-Build Checklist, Hand-Coded or Widget
Deciding between a custom build and a ready widget comes down to four checks:
- Confirm where your platform lets you add custom code: a block, an element, or an app install.
- Check the map provider's key needs separately; Google Maps and Mapbox both require a merchant-held credential, and Google Maps also requires a billing account.
- Decide how location data stays current: manual edits, a synced spreadsheet, or a live feed from your commerce platform.
- Test geolocation on a real phone with permission denied, not just allowed, since that is where near-me search usually fails.
What Product-Level Search Actually Requires
A store locator finds a place. A product locator answers a narrower question, which of your locations currently has a specific item, and that needs inventory data tied to each location, not just a map.
| Requirement | What it does | Shopify source |
|---|---|---|
| Location records | Store or pickup point | Location object |
| Inventory per location | Stock per product | inventoryLevels |
| Product filter | Show item in stock | storeAvailability |
The location and inventory rows come from Shopify's own Location API, and exist regardless of which app you install. Per-location availability for a variant is also exposed natively through the Storefront API's storeAvailability field, built for in-store pickup, though turning it into a map filter is still the app's job.
Ask a vendor two questions before committing:
- Does product availability update automatically from inventory, or does someone maintain it by hand?
- What does the page show when every nearby location is out of stock?
Final Thoughts
A store locator is done when the map loads cleanly, a geolocation test with permission denied still returns nearby results, and a product search, if you built one, excludes a location you know is out of stock. Everything past that is polish.
Most of this decision is about data, not design: where your locations live, how fresh they stay, and whether product availability is tracked anywhere close to real time. Get that right first, and the map underneath it is the easy part.
FAQ
Does store locator HTML code need a Google Maps API key?
Only if you pick Google Maps, which needs the merchant's own API key and a billing account. Mapbox needs its own access token instead, while maps built on OpenStreetMap-style data skip a key entirely.
What is the difference between a store locator and a product locator?
A store locator shows where your locations are. A product locator shows which of those locations has a specific item in stock right now, which needs inventory data behind the map.
Can I add a store locator without writing any code?
Yes: apps, plugins, and SaaS widgets generate the embed for you. Progus Store Locator is one option: a theme block on Shopify, a shortcode on WordPress, an App Market install on Wix, managed from the Shopify app or the web dashboard; anywhere else it's a single embed snippet.
Does geolocation always ask the shopper for permission?
No. An IP-based estimate can place a shopper at the city level without any prompt. That makes it a reasonable fallback for shoppers who decline the browser prompt.
Add a store locator to your website. About Store Locator ›