This guide walks you through setting up all required environment variables for the NERV Systems website.
-
Copy the example file:
cp .env.local.example .env.local
-
Edit
.env.localwith your actual values -
Never commit
.env.localto version control (already in .gitignore)
- Go to Google Analytics
- Click Admin (gear icon, bottom left)
- Under Property, click Create Property
- Fill in details:
- Property name:
NERV Systems - Time zone: Your region
- Currency: USD (or your preference)
- Property name:
- After creating property, click Data Streams
- Click Add stream > Web
- Fill in:
- Website URL:
https://www.nervsystems.com - Stream name:
NERV Website
- Website URL:
- Click Create stream
- You'll see your Measurement ID at the top right
- Format:
G-XXXXXXXXXX(always starts with "G-") - Copy this value to your
.env.local:NEXT_PUBLIC_GA_ID=G-ABC123XYZ
- After deploying with GA_ID set, visit your website
- In Google Analytics, go to Reports > Realtime
- You should see your visit appear within 30 seconds
- Active HubSpot account (Marketing Hub)
- Access to Forms and Settings
- Log in to HubSpot
- Click Settings (gear icon, top right)
- Navigate to Account Setup > Account Defaults
- Find HubSpot Account ID (8-digit number)
- Copy to
.env.local:NEXT_PUBLIC_HUBSPOT_PORTAL_ID=12345678
Check your HubSpot URL:
app.hubspot.com→ Region:na1app-na2.hubspot.com→ Region:na2app-eu1.hubspot.com→ Region:eu1
Update .env.local:
NEXT_PUBLIC_HUBSPOT_REGION=na1
You need to create forms for each type of lead capture on the website.
- In HubSpot, go to Marketing > Forms
- Click Create form > Embedded form
- Name:
NERV Demo Request - Add fields:
- First Name (required)
- Last Name (required)
- Email (required)
- Company/Organization (required)
- Phone Number
- Job Title
- Message/Interest Area
- Click Options > What should happen after someone submits this form?
- Select: Display thank you message
- Message: "Thank you! We'll be in touch within 24 hours."
- Click Publish
- Create another form:
NERV Contact - Add fields:
- First Name (required)
- Last Name (required)
- Email (required)
- Organization
- Phone Number
- Message (required)
- Publish
- Create form:
NERV TAK Solutions Interest - Add fields:
- Standard contact fields (name, email, org, phone)
- Organization Type (dropdown: Military, Law Enforcement, Emergency Services, Other)
- Current TAK Usage (text)
- Estimated TAK Users (number)
- TAK Deployment Timeline (dropdown: 0-3 months, 3-6 months, 6-12 months, 12+ months)
- Service Interest (checkboxes: Hosting, Consulting, Training, NERVA Plugin)
- Publish
For each form you created:
- In HubSpot Forms list, click the form name
- Click Share or Embed tab
- You'll see JavaScript embed code like:
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script> <script> hbspt.forms.create({ region: "na1", portalId: "12345678", formId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" <-- THIS IS YOUR FORM ID }); </script>
- Copy the
formIdvalue (UUID format) - Add to
.env.local:NEXT_PUBLIC_HUBSPOT_DEMO_FORM_ID=a1b2c3d4-e5f6-7890-abcd-ef1234567890 NEXT_PUBLIC_HUBSPOT_CONTACT_FORM_ID=b2c3d4e5-f6a7-8901-bcde-f12345678901 NEXT_PUBLIC_HUBSPOT_TAK_FORM_ID=c3d4e5f6-a7b8-9012-cdef-123456789012 # Lead Magnet Resource Forms (one per resource type) NEXT_PUBLIC_HUBSPOT_RESOURCE_ROI_FORM_ID=5421c5dd-9cfb-4a89-bc06-6681300dca8e NEXT_PUBLIC_HUBSPOT_RESOURCE_COMPARISON_FORM_ID=e7ffdcd0-72ed-4ee5-a4d4-db10ec01aae1 NEXT_PUBLIC_HUBSPOT_RESOURCE_DEPLOYMENT_FORM_ID=263caaa0-f00c-499f-870b-2d6a8dcc2249 NEXT_PUBLIC_HUBSPOT_RESOURCE_TECHNICAL_FORM_ID=9f3e2d38-d131-492f-a4df-410b16aeac42 NEXT_PUBLIC_HUBSPOT_RESOURCE_COMPLIANCE_FORM_ID=117045b6-5fe8-450f-9cbc-3db69ee06c8b NEXT_PUBLIC_HUBSPOT_RESOURCE_OPERATIONS_FORM_ID=19ddfddf-4788-4135-a91f-f0558aa766a1
- For each form, go to Options tab
- Under Send form notifications to, add:
contact@nervsystems.com
- Customize notification email subject and content
- Save changes
- Deploy your site with environment variables set
- Submit a test through each form
- Verify:
- Form submits successfully (success message appears)
- Submission appears in HubSpot: Marketing > Forms > [Form Name] > Submissions
- Notification email received
- Contact created in HubSpot: Contacts > Contacts
- Push your code to GitHub
- Import project in Vercel
- Go to Settings > Environment Variables
- Add each variable:
- Variable name:
NEXT_PUBLIC_GA_ID - Value: Your actual value
- Environments: Check all (Production, Preview, Development)
- Variable name:
- Click Save
- Redeploy for changes to take effect
- Import project in Netlify
- Go to Site settings > Build & deploy > Environment
- Click Add a variable
- Add each NEXT_PUBLIC_* variable
- Save and redeploy
For AWS Amplify, Railway, Render, etc., add environment variables through their respective dashboards. All variables must be available at build time since they start with NEXT_PUBLIC_.
Create .env.local with all real values - use your actual HubSpot and GA accounts.
Pros: Test full functionality locally Cons: Test data pollutes production analytics/CRM
Create .env.local with minimal or dummy values:
NEXT_PUBLIC_GA_ID=
NEXT_PUBLIC_HUBSPOT_PORTAL_ID=Pros: No pollution of production data Cons: Forms fall back to mailto:, no analytics
Create separate HubSpot and GA properties for development:
- GA Property: "NERV Systems - Dev"
- HubSpot Portal: Development account (free tier)
This is the recommended approach for teams.
- ✓ Keep
.env.localout of version control (.gitignore) - ✓ Use environment variables for all secrets
- ✓ Rotate credentials if accidentally committed
- ✓ Use separate credentials for dev/staging/prod
- ✓ Limit access to production credentials
- ✗ Never commit
.env.localto git - ✗ Never share credentials in Slack/email
- ✗ Never hardcode credentials in source code
- ✗ Never use production credentials in development
- ✗ Never log environment variables to console
Problem: Form shows error or falls back to mailto:
Solutions:
- Check browser console for errors
- Verify
NEXT_PUBLIC_HUBSPOT_PORTAL_IDis correct (8 digits only) - Verify
NEXT_PUBLIC_HUBSPOT_REGIONmatches your account - Verify form ID is correct UUID format
- Check HubSpot form is published (not draft)
- Verify domain is allowed in HubSpot form settings
Problem: No data in Google Analytics
Solutions:
- Verify
NEXT_PUBLIC_GA_IDformat starts with "G-" - Check browser console for GA script errors
- Disable ad blockers during testing
- Wait 24-48 hours for data to appear (Realtime is instant)
- Verify GA property is not filtered (filters can block traffic)
- Check Analytics Debug mode: Install GA Debugger Chrome extension
Problem: Changed .env.local but site still uses old values
Solutions:
-
Local development:
- Stop dev server (Ctrl+C)
- Restart:
npm run dev - Hard refresh browser (Cmd+Shift+R / Ctrl+Shift+R)
-
Production (Vercel):
- Vercel caches environment variables at build time
- After changing env vars, trigger a new deployment
- Go to Deployments > [Latest] > ... > Redeploy
Problem: Form ID doesn't work
Correct format:
NEXT_PUBLIC_HUBSPOT_DEMO_FORM_ID=a1b2c3d4-e5f6-7890-abcd-ef1234567890
Common mistakes:
- Missing dashes:
a1b2c3d4e5f678...✗ - With quotes:
"a1b2c3d4-e5f6..."✗ - Extra spaces:
a1b2c3d4-e5f6...✗ - Portal ID instead of Form ID ✗
Before deploying to production:
-
.env.localcreated locally and contains all required variables - Google Analytics property created and Measurement ID obtained
- HubSpot Portal ID verified (8 digits)
- HubSpot region confirmed (na1, na2, eu1, etc.)
- All necessary HubSpot forms created and published
- All HubSpot Form IDs obtained and added to
.env.local - Form notification emails configured to contact@nervsystems.com
- Local testing completed - forms submit successfully
- Local testing completed - analytics appear in GA Realtime
- Environment variables configured in production hosting platform
- Production deployment tested - forms work
- Production deployment tested - analytics tracking
- HubSpot submissions reviewed - data captured correctly
- Email notifications received from form submissions
If you encounter issues not covered in this guide:
- Check Next.js environment variables docs: https://nextjs.org/docs/basic-features/environment-variables
- Check HubSpot Forms API docs: https://developers.hubspot.com/docs/api/marketing/forms
- Check Google Analytics setup docs: https://support.google.com/analytics/answer/9304153
For NERV Systems specific questions, contact: dev@nervsystems.com