Skip to content
FunnelGuard

Fix guide by FunnelsGuard

'undefined', 'NaN' or 'null' showing on your page: how to fix it

PRF-288High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

undefined, null and NaN (short for 'Not a Number') are values used in JavaScript and other programming languages. They are meant for developers, not visitors. When a page tries to show a value that does not exist yet, or does maths on text, the raw word is printed instead.

Typical examples: a greeting that says 'Hi undefined', a cart total of 'NaN', a product price of '$null', or a countdown that reads 'NaN days'. They come from custom scripts, page builder widgets, form personalisation, dynamic pricing and apps that load data after the page opens.

Why it costs you leads or sales

Visitors read these words as 'this site is broken'. If the error sits next to a price, a form or a button, people stop trusting the page and leave. It is worse on checkout pages, where trust matters most. Because the page still loads, nothing alerts you, and it can stay live for weeks.

Where a price error stops a sale
  1. Ad clickVisitor lands on the product page
  2. Price loadsScript prints 'NaN' instead of the price
  3. Add to cartVisitor hesitates or leaves
  4. PurchaseSale never happens

A script fails to read the price, so the visitor sees NaN and leaves before the form or payment steps.

Visitors who continue past the pageExample numbers
Visitors who continue past the page (example)Clean page: 40 %; Page showing 'NaN': 22 %015314022Clean pagePage showing 'NaN'%

Example: illustrative numbers showing how a visible error can lower the share of visitors who move to the next step.

How to check if your site has it

Start with the pages that earn money: landing pages, pricing, cart, checkout, thank-you pages and any page with a personalised greeting or calculator.

Find error text by hand
  1. Search the page text

    Open the page, press Ctrl+F (Cmd+F on Mac) and search for undefined, null and NaN. Check the page after it has fully loaded.

  2. Test the states

    Change quantity, pick a variant, apply a coupon, switch country or currency, and open the page with and without URL parameters. Many errors only show after an interaction.

  3. Test as a new visitor

    Use a private window with no cookies and no logged-in session. Missing first-name or saved-data values often show up only here.

  4. Check mobile and slow loads

    Try a phone and a throttled connection. Values loaded late can briefly show 'undefined' before they fill in.

  5. Open the browser console

    Press F12 and look at the Console tab for red errors such as 'Cannot read properties of undefined'. They point to the script that fails.

How to fix it

The cause is nearly always one of three things: a value that is not set yet, a field that is empty, or text used in a calculation. Fix the source, and add a fallback so a missing value never shows as raw text.

Common causes and fixes
Where you see itLikely causeFix
Hi undefinedFirst name is not availableUse a fallback such as 'Hi there'
Price shows NaNPrice text like '$1,200' used in mathsStrip symbols and commas, then convert to a number
Field shows nullEmpty database or CRM fieldHide the element or show a default when empty
Shows undefined after loadingScript runs before data arrivesWait for the data, or render only when it exists
Fix by platform
  1. Find the source

    Search the page in the editor and in Custom HTML blocks, shortcodes and theme files. Deactivate plugins one at a time on a staging copy to find the one that prints the text.

  2. Fix empty custom fields

    In ACF or similar plugins, make sure the field has a value or add a default. In theme code, check the value before printing it.

Safe fallbacks for names and pricesjavascript
// Name with a fallback
const name = user && user.firstName ? user.firstName : 'there';
greetingEl.textContent = 'Hi ' + name;

// Price: clean the text, convert, and check before showing
const raw = priceEl.dataset.price; // e.g. '$1,200.00'
const value = parseFloat(String(raw).replace(/[^0-9.]/g, ''));
if (Number.isFinite(value)) {
  totalEl.textContent = '$' + value.toFixed(2);
} else {
  totalEl.textContent = ''; // hide rather than show NaN
}

How to confirm it's fixed

Confirmation checklist
  • Search the page for undefined, null and NaN after it fully loads
  • Repeat in a private window with no cookies
  • Test every variant, quantity, coupon and currency you offer
  • Test on mobile and on a slow connection
  • Check the browser console shows no related red errors
  • Check the page after clearing your cache and any CDN or plugin cache
Greeting and price block

Before

  • 'Hi undefined, your total is NaN'
  • Visitor doubts the site works
  • Checkout abandoned

After

  • 'Hi there, your total is $49.00'
  • Fallback covers missing names
  • Price is checked before it shows

How to prevent it happening again

Prevention habits
  • Give every dynamic value a default or fallback
  • Test pages as a new visitor after each theme, plugin or app update
  • Test calculators, pricing and personalised text with empty and unusual inputs
  • Keep custom scripts in one place so they are easy to review
  • Re-check key pages after any change to CMS fields, CRM fields or tag setups

How FunnelGuard handles this

FunnelGuard detects this issue only partly. It uses a text check: when you list words such as 'undefined', 'NaN' or 'null' as text that must be absent on a page, a robot visitor loads that page on its schedule and raises an alert if any listed word appears. The alert comes with a screenshot and a likely cause, after a re-check from a second region.

What it does not do: it does not scan your whole site for these words on its own, and it only checks the pages and journey steps you have set up. It will not find errors that appear only after inputs it does not make, such as a rare coupon, a specific variant or a logged-in account view, and it cannot judge whether a displayed value is correct. Note that a plain word like 'null' can also appear in legitimate text, so choose your list with care.

To cover the rest by hand, search key pages for the three words after each release, test variants, coupons, currencies and mobile, and review the console. Add your most important pages and checkout steps to a journey so the check runs there every time. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans include a 3-day free trial.

Frequently asked questions

Questions people ask

Why does my website show 'undefined'?

A script or template tried to print a value that does not exist, such as a missing first name or an empty field. The page then prints the word 'undefined' instead. Find the field or script that outputs it and add a fallback or fix the data source.

Why is my price showing NaN?

NaN means 'Not a Number'. It usually happens when code does maths on text such as '$1,200' or on an empty value. Remove symbols and commas, convert the text to a number and check it is valid before showing it.

Why does my page say 'Hi null' or 'Hello undefined'?

The personalisation could not find the visitor's name, often because they are new or came from a link without the data. Set a default such as 'Hi there' for when the name is missing.

How do I find 'undefined' or 'NaN' on my website?

Open each key page, press Ctrl+F or Cmd+F and search for undefined, null and NaN after it fully loads. Also test variants, coupons and currencies, use a private window and check the browser console for errors.

Can I hide the error text with CSS?

You can, but it is a poor fix. The value is still missing, so a price or name may be absent or wrong. Fix the source and add a fallback instead.

Can FunnelGuard detect 'undefined' or 'NaN' on my site?

Partly. If you list those words as text that must be absent on a page, FunnelGuard checks that page on schedule and alerts you if one appears. It does not scan pages you have not set up or find errors that need inputs it does not make.

Is the word 'null' always an error?

No. It can appear in normal copy, such as a name or a sentence. Check the context before treating it as a bug, and take care when adding it to an automated text check.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: text_absent if listed.

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.