Test whether a storefront remembers the chosen market

Before a storefront release, try this check on your staging site. A shopper arrives from the United States, switches to Canada, then opens the storefront in a new tab. They should still see Canada. A second shopper on the same connection should get the US store. The second shopper is the control. If they also see Canada, the release team has a different problem to investigate.


Write down what each shopper should see

Use the storefront’s neutral entry URL, with no country in the path or query string. Agree on the expected behavior with the team that owns the market selector. In this example, a signed-out US visitor starts in the US store and a shopper’s explicit choice persists across tabs in the same browser context.

Check

Browser state

Expected store

First visit

New shopper with no saved preference

United States

Return visit

Same shopper in a new tab after choosing Canada

Canada

Control visit

A second shopper in a fresh context

United States

 

Set up one US connection

In NiuProxy Rotating Residential Proxies, choose the United States and generate a sticky endpoint for the short test. Select username and password authentication. Copy the generated host, HTTP port, full username and password. Canada is selected in the storefront, so the three visits use the same US proxy settings.

Follow the CloakBrowser Quick Start for the initial Python setup. Install the GeoIP extra with pip install "cloakbrowser[geoip]". The example sets the browser language to en-US and lets CloakBrowser configure the timezone from the route at launch. Both contexts use the same launch settings.

Set NIU_SERVER to your HTTP endpoint, such as http://proxy.example:8080. Set NIU_USERNAME and NIU_PASSWORD to the generated credentials, and STORE_URL to the neutral storefront URL. Keep the credentials in your environment or secret manager. Use a staging storefront you control that is reachable through the proxy.

Run the three visits

Save the code as check_store_preference.py and run python check_store_preference.py. Replace current-store, Shop Canada, and the two store names with the labels on your site. The current-store element should become visible once routing resolves. After changing markets, its text should reflect the saved preference. If your site shows a preview before saving, add a wait for your site's save confirmation before first.close().

Each visit checks the exit country with a browser request before opening the storefront. If the diagnostic fails or reports a country other than the US, stop and check the route. Your storefront’s country decision is separate. Its own request logs are the place to confirm it.

Decide what to investigate

The first visitor sees the wrong store. Use the request timestamp to find the entry request in your edge or application logs. Check how the storefront assigned a country and which redirect or cache rule served the result.

Canada disappears on the return visit. Check when the picker writes its cookie or local storage and whether the neutral entry route reads that value. If it was saved and the route still chooses the US, review which rule takes precedence when a saved preference exists.

The second shopper lands in Canada. Check for a cached regional response or a routing rule that applies too broadly. Compare the return request with the control request. The control had no saved choice, so a matching result in both contexts is a reason to inspect shared routing or caching.

Python example

import os
from ipaddress import ip_address

from cloakbrowser import launch
from playwright.sync_api import expect

TRACE_URL = "https://www.cloudflare.com/cdn-cgi/trace"


def open_url(page, url):
    response = page.goto(url, wait_until="domcontentloaded", timeout=30_000)
    if response is None or not response.ok:
        status = response.status if response else "no response"
        raise SystemExit(f"Navigation failed ({status}).")


def expect_market(page, market, step):
    label = page.get_by_test_id("current-store")
    try:
        expect(label).to_be_visible(timeout=10_000)
        expect(label).to_have_text(market, use_inner_text=True, timeout=10_000)
    except AssertionError:
        raise SystemExit(f"{step}: expected {market}.") from None
    print(f"{step}: {market}")


def visit(context, url, market, step):
    page = context.new_page()
    open_url(page, TRACE_URL)
    lines = page.locator("body").inner_text().splitlines()
    trace = dict(line.split("=", 1) for line in lines if "=" in line)
    try:
        ip_address(trace.get("ip", ""))
    except ValueError:
        raise SystemExit(f"{step}: exit IP could not be verified.") from None
    if trace.get("loc") != "US":
        raise SystemExit(f"{step}: expected a US exit.")
    open_url(page, url)
    expect_market(page, market, step)
    return page


def main():
    proxy = {
        "server": os.environ["NIU_SERVER"],
        "username": os.environ["NIU_USERNAME"],
        "password": os.environ["NIU_PASSWORD"],
    }
    if not all(proxy.values()) or not proxy["server"].startswith("http://"):
        raise SystemExit("Supply the generated HTTP endpoint and credentials.")
    url = os.environ["STORE_URL"]
    browser = launch(
        proxy=proxy, locale="en-US", geoip=True, release_channel="stable"
    )
    try:
        shopper = browser.new_context()
        first = visit(shopper, url, "United States", "First visit")
        first.get_by_role("button", name="Shop Canada", exact=True).click()
        expect_market(first, "Canada", "After selection")
        first.close()
        visit(shopper, url, "Canada", "Return visit")
        visit(browser.new_context(), url, "United States", "Control visit")
        print("PASS")
    finally:
        browser.close()


if name == "__main__":
    try:
        main()
    except Exception as error:
        raise SystemExit(f"Check stopped ({type(error).__name__}).") from None

When all three checks pass, record the release number and the three store labels. On your next release, run the same check in CloakBrowser with a sticky US endpoint from NiuProxy Rotating Residential Proxies.

About the author

V
VivienContent Manager

Vivien specializes in content creation for proxy technology and cybersecurity, with extensive experience in SEO optimization and technical writing. She excels at transforming complex technical concepts into practical, easy-to-understand guides, helping users better understand and utilize proxy services. Outside of work, she's passionate about exploring the latest trends in internet technology.

NiuProxy Team

The NiuProxy team consists of seasoned internet technology experts dedicated to providing cost-effective proxy solutions to users worldwide. With years of deep expertise in the proxy service industry, we've accumulated extensive practical experience in residential IP management, data collection, and account security. Our team always prioritizes user needs, delivering stable and reliable support for social media marketing, e-commerce operations, web scraping, and other business scenarios through technological innovation and quality service.

NiuProxy Core Advantages

NiuProxy offers industry-leading competitive proxy services, focusing on exceptional value and ease of use. We provide a premium IP resource pool of over 50 million IPs covering 200+ countries and regions worldwide, supporting both dynamic residential proxies and static residential proxies to meet diverse business needs. Pricing starts as low as $0.7/GB, with free trials available for new users. Our platform supports dual protocols (HTTP and SOCKS5) and features a visual control panel for simple, intuitive operation. With 99.9% service stability backed by 24/7 technical support, your business operations run smoothly. Whether it's multi-account management for social platforms like TikTok, bulk operations for cross-border e-commerce, data scraping, or market research, NiuProxy delivers professional and efficient solutions.

All content on this blog is provided for educational and reference purposes only and does not constitute legal advice or warranties. Before using proxy services for data collection or other operations, please comply with the target website's terms of service and local laws and regulations. Consult professional legal counsel and obtain appropriate authorization when necessary.