On this page
What this issue is
An environment variable is a named value your app reads when it builds or runs, for example STRIPE_SECRET_KEY, CRM_API_URL or GTM_ID. It keeps secrets and per-environment settings out of your code.
After a redeploy the variable can be gone or empty. Common causes: it was only set for Preview, not Production; it was added in a dashboard after the last build, so the running build never saw it; it was renamed in code but not in the host; the project was moved or recreated; or a deploy script overwrote the .env file.
Why it costs you leads or sales
The pages look normal, so nobody complains until the numbers drop. Typical effects depend on which variable vanished:
| Variable type | What goes wrong | What you see |
|---|---|---|
| Email or SMTP key | Form submits but no notification is sent | Empty inbox, happy-looking thank-you page |
| CRM or webhook URL | Leads are not saved | Gaps in CRM records |
| Payment key | Checkout errors or hangs | Fewer orders |
| Tracking or tag ID | Tag loads with no ID, or not at all | Conversions vanish in GA4 or ad platforms |
| Public API key (maps, chat, booking) | Widget fails to load | Missing button or blank embed |
- Ad clickVisitor lands on the page
- Page loadsLooks normal after redeploy
- Form submitServer reads an undefined API key
- Lead reaches CRMNever arrives
- Conversion trackedNever fires
The page loads, so the break is hidden until the form step.
Example: illustrative numbers. Leads drop to zero in the CRM the day the variable disappears and stay there until someone notices.
How to check if your site has it
Compare the deploy to the last good one
Open your host's deploy log. Note the time of the first deploy after things last worked and what changed.
List variables for the Production environment
In your host's settings (for example Environment Variables in Vercel, Netlify or Render), check each variable your code needs exists for Production, not just Preview or Development.
Check the build log for warnings
Search for words such as undefined, missing, not set or cannot read. Many frameworks print a warning or fail the build when a required value is absent.
Check build-time versus run-time
Public values baked into the front end (for example names starting NEXT_PUBLIC_ or VITE_) are read at build time. If you added them after the last build, rebuild.
Run the journey yourself
Submit your own form, start a checkout to the payment step, and check the inbox, CRM and your analytics real-time report.
const required = ['CRM_API_URL', 'CRM_API_KEY', 'SMTP_HOST'];
const missing = required.filter((name) => !process.env[name]);
if (missing.length) {
throw new Error('Missing environment variables: ' + missing.join(', '));
}How to fix it
Add the variable to the right environment
Open your host's project settings, find Environment Variables, and add the name and value for Production. Check the spelling matches the code exactly, including case.
Redeploy with a fresh build
Trigger a new build. Existing builds do not pick up new values, and build-time variables are only baked in during the build.
Check server files
On a server you manage, confirm the .env file or systemd or Docker environment settings survived the deploy, and that your deploy script does not overwrite them.
Check wp-config.php
Constants and keys are often defined in wp-config.php or the host's environment panel. If a deploy or migration replaced that file, restore the missing defines from a backup.
Re-enter plugin keys
Open the plugin's settings (SMTP, CRM, payment) and confirm the API key fields are not blank.
Check container variables
If your site injects the container ID or a measurement ID from a variable, confirm the rendered page source contains the real ID, not an empty value.
Publish the correct version
In Workspace, check Versions and republish the last good one if constants were changed.
How to confirm it's fixed
- The new deploy finished and used the latest variables
- Test form submission arrives in the inbox
- The test lead appears in the CRM
- Checkout reaches the payment step without errors
- The conversion shows in GA4 real-time or the ad platform's test tool
- The browser console shows no failed requests to your own API
How to prevent it happening again
- Keep a documented list of every variable the site needs, per environment
- Add a startup check that fails the build when a required variable is missing
- Copy variables to Production when you add them to Preview
- Avoid renaming variables without updating the host in the same change
- Store secrets in a password manager or secrets service, not only in one dashboard
- Test the real journey right after every deploy
- Avoid deploying during peak ad hours
No check
- Deploy succeeds
- Form sends nothing
- You find out from missing leads days later
With a check and a journey test
- Build fails or the test fails within minutes
- You restore the variable
- Few or no leads lost
How FunnelGuard handles this
FunnelGuard detects this today, as a visible failure rather than a direct check of your settings. It does not read your environment variables. Instead, a robot visitor runs your real journeys on a schedule, such as the lead form, checkout or booking button, and checks each step, the tracking hits sent to platforms like GA4, Google Ads and Meta, and whether the test lead reaches the inbox and CRM.
The page loads but the form step fails because a value is missing.
Questions people ask
Why is my environment variable undefined after redeploy?
It is usually set on a different environment (Preview instead of Production), added after the last build, or named differently from what the code reads. Check the Production environment settings, match the exact name, and trigger a fresh build.
Why is my form not sending emails after a deploy?
The SMTP or email API key may be missing in the new deploy, so the code skips sending while the thank-you page still shows. Confirm the variables exist for Production, redeploy, and send a test submission.
Do I need to rebuild after adding an environment variable?
Yes, in most hosts. Existing builds do not pick up new values, and public front-end variables are baked in at build time. Trigger a new deploy after any change.
How do I find out which environment variable is missing?
Compare your list of required variables with the Production settings, and read the build log for undefined or missing warnings. A startup check that lists missing names makes this much faster.
Can a missing environment variable break tracking?
Yes. If a measurement or tag ID comes from a variable, the tag may load without an ID or not at all, and conversions stop appearing in analytics and ad platforms.
How can I catch this before customers notice?
Run a real journey test after each deploy and on a schedule: submit the form, then check the inbox, CRM and tracking. A synthetic monitor such as FunnelGuard does this automatically and alerts you when a step fails.
Does FunnelGuard read my environment variables?
No. It detects the effect: it runs your journeys, sees the failing step, missing tracking hit or lead that never arrives, and alerts you with a screenshot and likely cause.
Related issues
- OPS-292Deploy broke landing page or formFix guide
- OPS-293Deploy removed tracking snippetFix guide
- OPS-295Staging config in production (API URLs, test keys)Fix guide
- OPS-298Feature flag turned off funnel stepFix guide
- OPS-304Analytics consent config reset by deployFix guide
- OPS-308Deploys during peak ad hoursFix guide