On this page
What this issue is
Many sites save small bits of data in the browser: a cart ID, a consent choice, UTM values, a form draft. They use localStorage, sessionStorage or cookies for this. In some situations the browser refuses access. Then the call either throws an error or silently saves nothing.
Typical cases: the visitor blocks all cookies or site data, uses a hardened privacy browser or extension, or opens the site inside an in-app browser or embedded frame with storage restricted. Older Safari private mode also threw a QuotaExceededError on every write. Behaviour differs by browser and version, so never assume storage works.
Why it costs you leads or sales
Visitors who browse privately or block cookies are often cautious buyers. If the page breaks for them, they leave without telling you. You see no error, only a lower conversion rate for a group you cannot easily see.
- Landing page loadsPage renders normally
- Script saves to localStorageBrowser throws SecurityError
- Form or cart codeNever runs
- Lead or orderNot created
A single unguarded storage call can break everything after it.
Example: illustrative numbers showing how a storage error can cut conversions for visitors who block storage.
How to check if your site has it
Open a private window
Use Incognito, InPrivate or Private Browsing. Run your main funnel: submit a lead form, add to cart, start checkout.
Block all cookies and site data
In Chrome, go to Settings > Privacy and security > Third-party cookies or Cookies and other site data, and choose Block all cookies. In Safari, turn on Block all cookies under Settings > Privacy. Reload and test again.
Watch the console
Open DevTools (F12) > Console. Look for SecurityError, QuotaExceededError, or 'Access is denied for this document'.
Search your code
Search your theme and tag code for
localStorage,sessionStorageanddocument.cookie. Any use without try/catch is a risk.Test an embedded frame
If your form or booking widget runs inside an iframe, test it on a page where third-party storage is blocked. Frames are often the first thing to lose access.
The script hits a blocked storage call, throws, and the rest of the page logic stops.
How to fix it
The fix is the same everywhere: never call storage directly. Use a small safe wrapper that tests access, catches errors and falls back to a variable in memory. The data then lasts for the page view, which is enough for most flows.
const memoryStore = {};
function storageAvailable() {
try {
const k = '__test__';
window.localStorage.setItem(k, '1');
window.localStorage.removeItem(k);
return true;
} catch (e) {
return false;
}
}
const canStore = storageAvailable();
const safeStorage = {
get(key) {
try {
return canStore ? window.localStorage.getItem(key) : (memoryStore[key] ?? null);
} catch (e) {
return memoryStore[key] ?? null;
}
},
set(key, value) {
try {
if (canStore) { window.localStorage.setItem(key, value); return; }
} catch (e) {}
memoryStore[key] = String(value);
},
remove(key) {
try {
if (canStore) window.localStorage.removeItem(key);
} catch (e) {}
delete memoryStore[key];
}
};Add the wrapper
Place the safe storage wrapper in a shared script loaded before other code.
Replace direct calls
Swap every
localStorage.getItem/setItemandsessionStoragecall forsafeStorage. Wrapdocument.cookiewrites in try/catch too.Handle missing data
Make sure the flow still works when
getreturns null, for example by using a default value or asking the server.
Find Custom HTML tags
Open Tags and look for Custom HTML tags that use localStorage or cookies.
Wrap the calls
Add try/catch around each storage call inside the tag code.
Preview
Use Preview mode in a private window and check the tag still finishes.
Find the source
Check your theme, child theme and plugins that add scripts. Search the files for
localStorage.Patch your own code
Add the wrapper to your theme's JavaScript and use it. For plugin code, report the bug to the plugin author or switch plugins.
Avoid editing plugin files
Edits are lost on update. Use a child theme or a small custom plugin instead.
Search theme code
In Online Store > Themes > Edit code, search assets and sections for
localStorageandsessionStorage.Wrap your own code
Use the wrapper in theme.js or a custom asset. Check apps that inject scripts and contact the app developer if one fails.
Check custom code
Review Project settings > Custom code and page-level embeds for storage calls.
Wrap and republish
Add try/catch or the wrapper, then publish and retest in a private window.
How to confirm it's fixed
- Open a private window and block all cookies, then complete your lead form or checkout up to the payment step.
- The console shows no SecurityError or QuotaExceededError.
- Consent banner, cart and form still work, even if a saved value is lost on reload.
- The same flow also works in a normal window with storage allowed.
- Repeat in Chrome, Safari and Firefox, on desktop and mobile.
Before
- Direct localStorage.setItem calls
- Blocked storage throws an error
- Form and checkout scripts stop
After
- Calls wrapped in try/catch
- Falls back to memory
- Funnel completes for every visitor
How to prevent it happening again
- Make the safe wrapper the only way your code touches storage.
- Add a lint rule or code review check against direct localStorage use.
- Include a private-window and blocked-cookies run in your release checklist.
- Re-test after adding any new app, widget, chat tool or tag.
- Log JavaScript errors in a monitoring tool so storage errors show up.
How FunnelGuard handles this
FunnelGuard does not check this yet. A check for blocked storage is a possible future addition. Its robot visitor runs in a standard browser session, so it does not simulate private mode or blocked cookies.
What FunnelGuard does cover nearby: it runs your real journeys (lead forms, checkouts, booking and chat buttons) on a schedule, checks each step and the tracking hits, and sends one alert with a screenshot and a likely cause when a step fails. That can reveal a broken funnel from other causes, but it will not tell you that blocked storage is the reason for a failure seen only by some visitors.
To watch for this yourself, run the private-window and blocked-cookies test after each release, and use a browser error-logging tool to collect SecurityError and QuotaExceededError reports from real visitors.
Questions people ask
Why is my website not working in private browsing mode?
Often because your code uses localStorage, sessionStorage or cookies and the browser blocks or limits them in private mode. If the code does not catch the resulting error, the script stops and forms or carts break. Wrap storage calls in try/catch and add a memory fallback.
What does 'SecurityError: The operation is insecure' mean for localStorage?
It means the browser refused your script access to storage, usually because cookies or site data are blocked, or the page runs in a restricted frame. Accessing window.localStorage can itself throw. Guard it with try/catch.
Why do I get QuotaExceededError when setting localStorage in Safari?
Older Safari private browsing set the storage quota to zero, so every write failed with QuotaExceededError. Newer versions behave differently, but the safe fix is the same: catch the error and fall back to memory.
How do I check if localStorage is available in JavaScript?
Try writing and removing a test key inside a try/catch block, and return false if it throws. Do not rely on if (window.localStorage) alone, because the access can throw. Use the result to choose between localStorage and an in-memory object.
Should I use cookies instead of localStorage as a fallback?
Not as the only fallback, because blocked cookies are often blocked together with storage. An in-memory variable works for the current page view, and the server can hold anything that must persist, such as a cart ID tied to a session.
How do I test my site with cookies and localStorage blocked?
Open a private window, and in browser settings block all cookies and site data. Then run your key journeys with DevTools open and watch the console for errors. Repeat in Safari and Firefox.
Does FunnelGuard detect blocked localStorage?
No. FunnelGuard does not check this yet; it is a possible future check. It does run your real funnel journeys on a schedule and alerts you when a step fails, but it does not simulate private mode.
Related issues
- PRF-116Uncaught JavaScript exception on page loadFix guide
- PRF-120JS error only after clicking submit breaks the formFix guide
- PRF-127JS error only in Safari (unsupported API)Fix guide
- PRF-130Service worker serving stale or broken cached versionFix guide
- PRF-135Form submits but shows no feedback (silent failure)Fix guide
- PRF-117Console error on a funnel stepFix guide