Back button after a Shopify geolocation redirect: no trap

A shopper in Toronto clicks a link to your US store. The page starts to load, then the address bar changes and they are on the Canadian store. They did not ask for that, so they do what everyone does: they press Back. The US page begins to load, and then the address bar changes again. They press Back twice, quickly. Same thing. They close the tab.

That is the back button trap, and it is one of the oldest complaints about automatic redirects of any kind. It costs a visit each time it happens, and the merchant never hears about it, because a shopper who cannot go back does not write in. This post explains where the trap comes from, what GeoBeacon does about it, and the few situations where pressing Back does something a shopper might not expect.

Where the trap comes from

A browser's Back button reloads the previous entry in its history. If that entry is a page whose script redirects visitors from Canada, and the visitor is still in Canada, the script does its job again. Nothing is broken. The script just has no idea it already ran.

There are two ways a redirect script can avoid this. It can replace the history entry when it redirects, so the original page is no longer there to go back to. Or it can remember that it already redirected this browser and stay quiet the second time. The first one avoids the bounce and takes away the shopper's way back to the page they asked for. The second one leaves the history alone and lets Back mean what it always means.

What GeoBeacon does

GeoBeacon takes the second route. In automatic redirect mode the order of events is:

  1. The script works out that this visitor matches a rule and should go somewhere else.
  2. It writes the decision into the browser's local storage, with an expiry date.
  3. Only then does it navigate.

The write comes first on purpose. When the shopper presses Back, the original page loads, the script starts, finds the stored decision, and stops before it even asks which country the visitor is in. If you have Log decisions to the console switched on in the app embed, the line reads skipped: remembered. The shopper stays on the page they went back to.

The navigation itself is an ordinary one. For a rule that points at another store or site, GeoBeacon assigns the new address, which adds a history entry and keeps the old one. For a rule that points at a market on the same store, it submits Shopify's own localization form, the same request your theme's country selector sends, and Shopify answers with a redirect to the same page in the new market. In both cases the page the shopper started on is still in their history.

How long the memory lasts

The stored decision lasts for the number of days in the setting called Remember the visitor's choice for, on the Behaviour page. The default is 30 and the maximum is 365.

Setting it to 0 does not switch the memory off. A zero is treated as 30 minutes, exactly so that a store which wants to ask again on every visit still cannot bounce a shopper who presses Back. Half an hour covers a browsing session; a visit tomorrow starts fresh. The post on how long to remember a choice goes through picking a number.

Popup mode has no trap to begin with

In popup mode nothing moves until the shopper clicks. If they accept, the choice is saved and they are taken to the other market or store, and Back behaves as above. If they decline, or press Escape, or click outside the card, that is saved too and the popup stays away for the same period. A shopper who chose to go and then comes back has made two deliberate moves, and the store respects both.

This is one more reason the comparison of the two modes leans towards the popup for most stores. Automatic redirect is safe from the trap in GeoBeacon, but the popup never needed protecting.

Back changes the page, not the market

Here is the part that surprises people. After a same-store market switch, pressing Back returns to the earlier URL. It does not tell Shopify to forget the market.

  • One domain, no subfolders. The market lives in a cookie. The earlier URL is the same URL, and it now shows the new market's currency and prices. To the shopper it looks as if Back did nothing, which is roughly true: they were already on this page.
  • Subfolders, such as /en-ca. The URL carries the market. Going back to a URL without the prefix shows the market that URL belongs to, and GeoBeacon stays quiet because the choice is remembered.
  • Separate domains or separate stores. Back returns to the first domain, with its own prices, and nothing moves the shopper again.

None of these is a trap. In the second and third the shopper ends up browsing the market they originally asked for, which is a fair reading of what pressing Back means. If they want the other market after all, your theme's country selector is the way there, and the post on selectors and popups explains why a store should have both.

Two stores that both run GeoBeacon

With a US store and a Canadian store each redirecting the other's visitors, there is a second way to bounce: the shopper presses Back to the US store, and then Forward, or clicks a link, to the Canadian one, which looks at them and sends them somewhere else again.

Each store keeps its own memory, since browser storage is per domain. The US store remembers it already sent this visitor away. The Canadian store has a separate rule for this: list your other storefronts as known hosts and a visitor who arrives from one of them is left alone. The log line is skipped: came-from-own-store. Between the two, a shopper can move back and forth between your stores with the browser's buttons and neither store will argue. The referrer rule post has the setup.

When Back can still surprise someone

  • Testing with the forced country parameter. A URL with ?geobeacon=CA simulates a visitor from Canada, and a forced visit is never remembered. Press Back to that URL and the redirect fires again. That is the test tool working, not the store misbehaving. To see what a real visitor gets, test without the parameter from a matching location, or clear the parameter before pressing Back.
  • A browser that refuses storage. If local storage is blocked outright, there is nowhere to keep the decision. Most browsers restore the previous page from the back/forward cache without running its scripts again, so the shopper usually lands safely. Where that cache is not used, a redirect can repeat. Stores with privacy-minded audiences are better served by popup mode.
  • Cleared site data. A shopper who clears storage, or whose browser clears it when the window closes, starts over as a new visitor. They will be redirected once more on their next visit, and Back will work again from there.
  • A different browser. The memory belongs to the browser, so the same person on a phone and a laptop is two visitors.

Check it on your own store

  1. In the theme editor, open the GeoBeacon app embed and turn on Log decisions to the console. Save, then open a private window.
  2. Visit a product page from a location that matches a rule, or ask a colleague in that country to do it. Do not use the test parameter for this check.
  3. Let the redirect happen, then press Back.
  4. The original page should load and stay. The console should show skipped: remembered.
  5. Press Forward. You should arrive at the destination without a second redirect or a popup.

If the page bounces at step four, look at what else is installed. A theme's own redirect snippet, a second geolocation app left over from an earlier setup, or a redirect at the DNS or CDN level will all run without knowing about GeoBeacon's memory. The redirect loop post is the checklist for finding which one it is.

A redirect is a guess about what the shopper wants. The Back button is the shopper telling you the guess was wrong. A store that listens the first time keeps the visit, and GeoBeacon is built to listen.

Frequently asked questions

What happens when a shopper presses Back after a GeoBeacon redirect?

They return to the page they were on, and it stays put. GeoBeacon saves the decision in the browser before it navigates, so when the original page loads again the script sees a remembered choice and does nothing. The shopper is not sent forward a second time.

Why do some geolocation redirects trap the Back button?

Because the redirect runs on every page load with no memory of having run before. Back loads the original page, the script detects the same country, and redirects again. From the shopper's side the Back button appears broken. The fix is to remember that a redirect already happened in this browser, which GeoBeacon does for the number of days you set, or for 30 minutes if you set zero.

Does pressing Back undo the market switch?

No. Back changes the page, not the market. When GeoBeacon switches a shopper to another market on the same store, Shopify remembers that market for the visit. Going back shows the earlier URL, and which prices appear there depends on how your markets are set up: with one domain for everything, the earlier URL now shows the new market's prices; with subfolders or separate domains, the URL decides. To switch back deliberately, the shopper uses your country selector.

While testing with ?geobeacon=DE the redirect fires again after Back. Is that a bug?

No. A forced test country is never remembered, so that a test does not silence the store for you for 30 days. Each load of a URL carrying the test parameter runs the rules fresh. Real visitors do not have the parameter and get the remembered behaviour.

Can a shopper get stuck if their browser blocks storage?

It is the one case where the memory cannot be kept. If the browser refuses storage entirely, GeoBeacon has nowhere to record the choice. Modern browsers usually restore the previous page from their back/forward cache without running scripts again, which covers most of these visits, and popup mode removes the risk because nothing moves without a click.