Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Debug output and console.log leaking into your page: fix it

PRF-291Medium impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

Debug output is information a developer prints while building a site to see what the code is doing. It should never reach visitors. It leaks in two ways. On the page: raw text such as Notice: Undefined variable, Warning: Cannot modify header information, a var_dump() of an array, a JSON blob or a stack trace shown above your header or inside a form. In the browser console: console.log() calls that print form values, API responses, tokens or tracking payloads. Visitors rarely open the console, but anyone can, and so can scrapers and competitors.

Common causes are WP_DEBUG_DISPLAY left on in WordPress, a theme or plugin that echoes variables, a staging config pushed to production, a custom script with leftover console.log lines, and a tag in Google Tag Manager running in preview or debug mode.

Why it costs you leads or sales

Visible errors make a site look broken or unsafe, and people leave before they fill in a form or pay. Errors printed before the page headers can also break redirects, cookies and tracking scripts. Leaked data is a bigger risk: email addresses, order details, API keys or file paths in output can be a privacy problem and give attackers useful clues. Console logs alone rarely hurt conversion, but they often point to code that is failing quietly.

How debug output can hurt a lead form
  1. Visitor submits formForm posts to the server
  2. Debug output printedWarning text sent before headers
  3. Redirect failsThank-you page never loads
  4. Conversion tagNever fires on the thank-you page

A PHP warning printed before the headers is sent can break the redirect to the thank-you page.

How to check if your site has it

Check a page for debug output
  1. Read the page as a visitor

    Load your key pages (home, landing pages, form, checkout, thank-you page) and look at the top, the footer and inside forms for stray technical text.

  2. Open the browser console

    In Chrome press F12 (Cmd+Option+I on Mac), open the Console tab, reload the page and read the messages. Look for logged objects, emails, tokens and error messages.

  3. Search the page source

    Press Ctrl+U (Cmd+Option+U on Mac) and search for Notice:, Warning:, Fatal error, Stack trace, Array (, object( and debug.

  4. Test the actions, not just the pages

    Submit the form, add to cart and open the chat widget with the console open. Many logs only appear on interaction.

  5. Check Google Tag Manager

    Make sure no custom HTML tag contains console.log or debugging code, and that the live container version is published, not a preview.

How to fix it

Remove debug output by platform
  1. Turn off error display

    In wp-config.php set WP_DEBUG to false, or keep logging but hide output with WP_DEBUG_DISPLAY false.

  2. Find the source

    Deactivate plugins one by one on a staging copy, or switch to a default theme, to see which one prints the output. Update or replace it.

  3. Remove leftover code

    Search your theme and custom code for var_dump, print_r, error_log echoes and console.log, and delete them.

wp-config.php: log errors, do not show themphp
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Drop console calls in production (esbuild)javascript
require('esbuild').build({
  entryPoints: ['src/app.js'],
  bundle: true,
  minify: true,
  drop: ['console', 'debugger'],
  outfile: 'dist/app.js'
});

How to confirm it's fixed

Confirmation checks
  • Key pages load with no stray technical text, in a private window.
  • Page source has no Notice:, Warning:, Fatal error or var_dump output.
  • Console is clean on load and after submitting forms or adding to cart.
  • The form still redirects to the thank-you page.
  • Server error logs still record errors, but nothing is shown to visitors.

How to prevent it happening again

Release habits

Without a process

  • Debug flags set by hand on the live server
  • Logs added in a hurry and never removed
  • Staging config copied to production

With a process

  • Separate production config with debug off
  • Build step removes console calls
  • Release checklist includes a console and source check

Add a linter rule such as ESLint's no-console to catch logs before they ship, and review the live site after every theme, plugin or tag change.

How FunnelGuard handles this

FunnelGuard does not check for debug output or console.log leaks yet. It is a possible future check. Today, FunnelGuard runs your real customer journeys on a schedule, from the EU or the US, and checks each step, the tracking hits sent to ad and analytics platforms, and whether test leads reach your inbox and CRM. That can surface the symptoms debug output causes, such as a form that no longer reaches its thank-you step or a conversion tag that stops firing, but it will not tell you that debug text is the reason.

To watch for this issue yourself, add the console and page-source checks above to your release checklist, keep error display off in production, and use a free tool such as Chrome DevTools or Lighthouse's best practices report to spot console errors. FunnelGuard also offers a free read-only website audit.

Questions people ask

Why is my website showing PHP errors or warnings on the page?

Your server or CMS is set to display errors, usually through display_errors or WP_DEBUG_DISPLAY. Turn display off in production and log errors to a file instead, then fix the code or plugin that causes the warning.

Is console.log on a live website a security risk?

It can be. Anyone can open the browser console, so logged form values, tokens, API responses or personal data are visible to them. Remove logs that print sensitive data and strip console calls in production builds.

How do I remove console.log from production?

Delete the calls from your source, or configure your build tool to drop them, for example esbuild's drop option or Terser's drop_console. Add the ESLint no-console rule so new ones are caught before release.

How do I turn off WP_DEBUG on a live WordPress site?

Edit wp-config.php and set WP_DEBUG to false, and WP_DEBUG_DISPLAY to false if you want logging without output. Save the file and reload the page to confirm the messages are gone.

Can debug output break my contact form or tracking?

Yes. Output printed before headers are sent can stop redirects and cookies, so visitors may not reach the thank-you page and conversion tags may never fire. Fix the output, then test the form end to end.

How can I check my site for leaked debug data?

Load key pages in a private window, open the browser console, and search the page source for terms like Notice:, Warning:, Fatal error and var_dump. Repeat after submitting forms and adding to cart.

Does FunnelGuard detect console.log or debug output?

No, not yet. It is a possible future check. FunnelGuard does monitor your form and checkout journeys and tracking hits, which can reveal related breakage.

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.