Skip to content
FunnelGuard

Fix guide by FunnelsGuard

localStorage required, fails in private mode: how to fix it

CNV-379Low impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

localStorage is a small store in the browser that your scripts use to remember things: a cart ID, a half-filled form, a step number, a consent choice. It normally works fine. But in some cases it is unavailable: private or incognito windows in some browsers, browsers set to block all site data, or a full storage quota.

Why it costs you leads or sales

A script that crashes on a storage call can leave a multi-step form stuck on step one, a cart that never saves, or a popup that will not close. The visitor sees a button that does nothing. They rarely report it. They leave.

The share of visitors affected is usually small, which is why the impact is low. But privacy-minded visitors are often the same people who compare options carefully, and the failure is silent in your reports because no error is shown on the page.

How a storage error stops a funnel
  1. Visitor opens pagePrivate window, storage blocked
  2. Script saves steplocalStorage.setItem throws an error
  3. Form moves onCode after the error never runs
  4. Lead submittedNever reached

A thrown error on the storage call stops the script, so later steps never run.

A storage error freezes the page

The script throws on the storage call and the button stops responding.

How to check if your site has it

Test your site with storage blocked
  1. Open a private window

    Use Safari Private, Chrome Incognito and Firefox Private Window. Walk through your main form or checkout.

  2. Block site data on purpose

    In Chrome, open Settings > Privacy and security > Third-party cookies, or use Site settings to block cookies and site data for your domain. In Firefox, use Settings > Privacy & Security > Custom and block cookies. Reload and retry.

  3. Open the console

    Press F12 and open the Console tab. Look for errors mentioning localStorage, SecurityError, QuotaExceededError or 'Access is denied'.

  4. Search your code

    Search your theme, plugins and tag manager scripts for localStorage and sessionStorage. Check each call is inside try/catch.

  5. Test in-app browsers

    Open your page from a link inside social apps and email apps. These browsers can have stricter storage rules.

How to fix it

The fix is the same everywhere: never call storage directly. Use a small helper that tests storage once, catches errors and falls back to memory.

Safe storage helper with in-memory fallbackjavascript
const safeStorage = (function () {
  const memory = {};
  let ok = false;
  try {
    const k = '__test__';
    window.localStorage.setItem(k, '1');
    window.localStorage.removeItem(k);
    ok = true;
  } catch (e) {
    ok = false;
  }
  return {
    get: function (key) {
      try { return ok ? window.localStorage.getItem(key) : (memory[key] || null); }
      catch (e) { return memory[key] || null; }
    },
    set: function (key, value) {
      try { if (ok) { window.localStorage.setItem(key, value); return; } }
      catch (e) {}
      memory[key] = String(value);
    },
    remove: function (key) {
      try { if (ok) window.localStorage.removeItem(key); }
      catch (e) {}
      delete memory[key];
    }
  };
})();
Where to apply the fix
  1. Replace direct calls

    Swap every localStorage.getItem/setItem for the helper above. Keep important data, like a cart ID, on the server so a lost browser store does not lose it.

How to confirm it's fixed

Confirmation checks
  • The form submits in a private window in Safari, Chrome and Firefox.
  • The checkout or cart works with site data blocked.
  • The console shows no localStorage errors.
  • Tracking and consent scripts still run after the storage call.
  • A test lead reaches your inbox or CRM.
Direct call vs safe helper

Before

  • Script calls localStorage directly
  • Error stops all code after it
  • Form or button does nothing in private mode

After

  • Calls go through a try/catch helper
  • Falls back to memory when storage is blocked
  • Form submits even without saved progress

How to prevent it happening again

Prevention habits
  • Ask developers and agencies to use a storage helper, never raw calls.
  • Include a private-window test in your release checklist for every form and checkout change.
  • Keep key state, like carts and lead IDs, on the server or in a cookie as a backup.
  • Retest after installing or updating plugins, apps and tag manager scripts.
  • Watch your browser console for errors after each launch.

How FunnelGuard handles this

FunnelGuard does not check this yet. It has no private-mode or blocked-storage variant of its robot visitor, so it will not tell you that a script fails when localStorage is unavailable. It is a possible future check.

What FunnelGuard does do nearby: it runs your real journeys on a schedule, checks each step, and checks tracking hits and test leads. If a script error stops a form for all visitors, a failed step is re-checked from a second region and then you get one alert with a screenshot and a likely cause. That only covers the standard browser setup, not private mode.

To watch for this issue today, add a private-window test to your launch checklist, and use your browser's developer tools or a JavaScript error tracker to see storage errors. The free plan (1 site, 2 journeys, daily checks) helps cover the main journeys while you test the private-mode cases by hand.

Questions people ask

Why is localStorage not working in private mode?

Some browsers and settings block or limit site storage in private windows or when site data is blocked. The call can throw an error such as SecurityError or QuotaExceededError. Wrap storage calls in try/catch to handle it.

How do I check if localStorage is available in JavaScript?

Try writing and removing a test key inside a try/catch block. If it throws, storage is unavailable. Do not rely only on checking whether window.localStorage exists.

Why does my form work normally but not in incognito mode?

Your form script may use localStorage or sessionStorage and crash when it is blocked. The error stops later code, such as the step change or submit handler. Check the console in a private window.

What is a good fallback when localStorage is blocked?

Use an in-memory variable for the current page, or a cookie for small values. For important data such as a cart or lead ID, store it on the server. Visitors should still complete the form without saved progress.

Is localStorage safe to use for carts and forms?

It is fine as a convenience, but not as the only place a cart or form state lives. Browsers can clear, block or limit it. Keep key data server-side and treat storage as optional.

Does FunnelGuard test my site in private mode?

No. FunnelGuard does not have a private-mode or blocked-storage check yet. It does run your real journeys on a schedule and check steps, tracking and test leads in its standard browser setup.

How do I test my website in private browsing?

Open a private window in Safari, Chrome and Firefox and complete your main form or checkout. Keep the console open to see errors. Also try blocking site data for your domain in browser settings.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.