Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Staging config in production: find and fix test API URLs and keys

OPS-295High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Most sites have at least two environments. Staging is a private copy where you test changes. Production is the live site your visitors and ad traffic reach. Each one has its own settings: API addresses, payment keys, analytics IDs, form endpoints and CRM connections.

Staging config in production happens when staging values end up on the live site. It usually follows a deploy, a database or settings copy, or a hardcoded value that nobody swapped before release. Typical examples are https://api.staging.example.com, a Stripe key starting with pk_test_, a GA4 ID from a test property, or a form action pointing at a sandbox.

Why it costs you leads or sales

The page still loads and looks normal, so nobody notices. But behind it, things fail quietly. A form may post to a staging endpoint, so leads never reach your CRM. A checkout using a test key cannot take real payments. Tracking sent to a test property means your ad platforms and reports see nothing, so campaigns optimise on missing data.

How a staging API URL loses a lead
  1. Ad clickVisitor lands on the live page
  2. Form submitPage looks fine and shows a thank-you
  3. Staging APIForm posts to the staging URL
  4. CRM and inboxLead never arrives
  5. Ad conversionNot recorded or sent to a test property

The visitor sees a working form, but the data goes to the wrong place.

Leads reaching the CRM before and after a bad deployExample numbers
Leads reaching the CRM before and after a bad deploy (example)Before deploy: 24 leads per day; After deploy: 0 leads per day0918240Before deployAfter deployleads per day

Example: a form posting to a staging endpoint drops CRM leads to zero while visitors still see a thank-you page.

How to check if your site has it

Check the live site, not staging. Open a key page in a private window and look at what it actually loads.

Check the live site for staging values
  1. View the page source

    Open the live page, right-click and choose View page source. Search (Ctrl+F or Cmd+F) for staging, stage, dev., test, sandbox and localhost.

  2. Watch the Network tab

    Open browser DevTools, go to Network, reload and submit your form. Look at the request URLs. Any call to a staging or sandbox host is a problem.

  3. Check payment keys

    Search the source for pk_test_. Live Stripe publishable keys start with pk_live_. Other providers also separate test and live keys, so check their docs.

  4. Check tracking IDs

    In Network, filter for collect or g/collect and confirm the GA4 measurement ID (G-XXXXXXX) matches your live property. Do the same for Meta pixel and Google Ads IDs.

  5. Check the deployed settings

    Review environment variables or config files in your host or CMS for the production environment and compare them with the staging values.

Common staging values and what to look for
SettingStaging looks likeLive should look like
API base URLapi.staging.example.comapi.example.com
Stripe publishable keypk_test_...pk_live_...
GA4 measurement IDID of a test propertyID of your live property
Form endpointSandbox or test URLProduction form or CRM URL
Site URL / canonicalstaging.example.comwww.example.com

How to fix it

The fix is to replace each staging value with its live equivalent, then redeploy. Where you do that depends on your platform.

Replace staging values by platform
  1. Check Settings and General

    Under Settings > General, confirm WordPress Address and Site Address are your live domain.

  2. Check plugin settings

    Open your form, payment and SEO plugins and replace test API keys or sandbox modes with live ones. Many have a Test mode toggle.

  3. Check wp-config.php

    Look for hardcoded constants such as WP_HOME, WP_SITEURL or custom API keys and make sure they hold live values.

Search a codebase for staging leftoversbash
grep -rniE "staging|sandbox|localhost|pk_test_|sk_test_" ./src ./public ./config --exclude-dir=node_modules

How to confirm it's fixed

Confirm the fix
  • Page source has no staging, sandbox or localhost strings
  • Network requests from the form go to production hosts
  • Payment keys on the page start with the live prefix
  • GA4, Ads and Meta hits carry your live IDs
  • A test lead reaches the inbox and CRM
  • Cached and CDN copies are purged so old values are gone

How to prevent it happening again

Prevention habits
  • Keep staging and production settings in separate environment variables, never in shared code
  • Never copy a staging database or settings export over production without a clean-up step
  • Add a pre-release check that fails the build if staging, pk_test_ or localhost appears in output
  • Use hostname-based tag rules so test IDs cannot fire on the live domain
  • Re-test a form and a checkout right after every deploy
  • Document who owns each key and where it lives
Config after a clean release

Staging config live

  • Form posts to a staging endpoint
  • Checkout uses pk_test_ key
  • Tracking goes to a test property

Live config

  • Form posts to production CRM
  • Checkout uses pk_live_ key
  • Tracking reaches the live property

How FunnelGuard handles this

FunnelGuard detects this issue only partly. It runs your real customer journey on a schedule and applies two checks that relate to it: a text_absent check and a tag_ids check.

With text_absent, you can name text that must not appear on a page, such as staging or a test hostname, and FunnelGuard flags the step if it shows up in the page. With tag_ids, it checks that the tracking hits sent to ad and analytics platforms carry the IDs you expect, so a test GA4 or pixel ID is caught. A failure is re-checked from a second region before one alert goes out with a screenshot and a likely cause.

What it does not check: your server-side settings, environment variables or secret stores, API URLs that never show in the page or tracking hits, or whether a payment key is a test or live one unless it appears as text you told it to look for. It never enters real card details, so it cannot prove a live payment works.

Questions people ask

Why is my live site using staging settings?

Usually a deploy, settings copy or database import carried staging values into production, or a value was hardcoded and never swapped. Compare your production and staging environment variables to find the difference.

How do I check if my website is using a Stripe test key?

View the page source or Network tab and search for pk_test_. A live publishable key starts with pk_live_. Also check the Stripe dashboard to see whether real payments are being received.

Why are my form leads not reaching my CRM after a deploy?

The form may be posting to a staging endpoint or using a test API key. Check the form request in the browser Network tab and confirm it goes to your production URL, then submit a test lead.

Why is GA4 showing no data after a release?

The live site may be sending hits to a test measurement ID, or the tag was swapped for a staging container. Check the G- ID in the collect request and compare it with your live property.

How do I stop staging config reaching production?

Keep separate environment variables per environment, add a build check that fails on staging strings or test keys, and never copy staging settings over production. Test a form and checkout after each deploy.

Can a monitoring tool detect staging config in production?

Partly. A tool like FunnelGuard can flag staging text on a page and check that tracking hits carry the expected IDs, but it cannot see server-side settings or secret stores, so review those by hand.

Do I need to rotate keys if a test key was live?

Test keys are low risk, but a secret key exposed in page source should be revoked and replaced. Always check the provider's dashboard for unexpected activity.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: text_absent, tag_ids.

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.