# Lead Capture Testing Checklist


**Last Updated:** 2026-03-20

## Pre-Deployment Checklist

### Code Review
- [ ] Popup component included (`<?php include '../components/lead-capture-popup.php'; ?>`)
- [ ] Trigger script included (`<script src="/v2/js/lead-capture-triggers.js"></script>`)
- [ ] No JavaScript errors in console
- [ ] No PHP errors in logs
- [ ] Copy detection works (headline/description match page)

### Configuration
- [ ] HubSpot API token configured
- [ ] HubSpot form GUID matches HubSpot form
- [ ] Google Sheets credentials configured
- [ ] Google Sheets spreadsheet ID correct
- [ ] Copy patterns added (if new page type)

## Functional Testing

### Popup Display
- [ ] Popup appears on time trigger (wait 30-60s) — *skip on `/tools`; see below*
- [ ] Popup appears on scroll trigger (scroll 25-40%) — *skip on `/tools`*
- [ ] Popup appears on exit intent (move mouse to top) — *skip on `/tools`*
- [ ] Popup appears on manual trigger (`window.leadCapturePopup.show('manual')`)

### Tools pages (`/tools` hub and calculators)

- [ ] **No** automatic popup after extended wait (≥90s), deep scroll, or exit-intent gestures
- [ ] Manual path works: footer **Rückruf anfordern** or `window.leadCapturePopup.show('manual-callback')` opens popup
- [ ] Copy matches tools context (headline/description from `lead_capture_copy.php` / detector)
- [ ] Popup doesn't appear if form was previously submitted (within 30 days)
- [ ] Popup doesn't appear multiple times on same page

### Form Functionality - Step 1
- [ ] Name field accepts input
- [ ] Phone field accepts input
- [ ] Phone validation works (shows error for invalid format)
- [ ] Real-time phone validation works (as user types)
- [ ] Submit button shows loading state
- [ ] Form submits successfully
- [ ] Step 2 appears after successful submission
- [ ] Error messages display correctly (if validation fails)

### Form Functionality - Step 2
- [ ] Email field accepts input (optional)
- [ ] Notes field accepts input (optional)
- [ ] Call preference radio buttons work
- [ ] Back/Close button works
- [ ] Submit button shows loading state
- [ ] Form submits successfully
- [ ] Success state appears after submission
- [ ] Success state shows correct message

### Form Functionality - Success State
- [ ] Success message displays correctly
- [ ] Close button works
- [ ] Popup closes on button click
- [ ] Popup closes on overlay click
- [ ] Popup closes on ESC key
- [ ] Form resets after closing

## Integration Testing

### HubSpot Integration
- [ ] Contact created in HubSpot (Step 1)
- [ ] Contact has correct name
- [ ] Contact has correct phone
- [ ] Contact has temporary email (`lead-{leadId}@temp.ordio.com`)
- [ ] Contact updated in HubSpot (Step 2)
- [ ] Contact has correct real email (replaces temp email)
- [ ] Contact has correct notes
- [ ] Contact has correct call preference
- [ ] UTM data synced to HubSpot
- [ ] Lead source synced to HubSpot
- [ ] Page URL synced to HubSpot
- [ ] Activity tracking works (form submission in timeline)

### Google Sheets Integration
- [ ] Row created in Google Sheets (Step 1)
- [ ] Row has correct timestamp
- [ ] Row has correct name
- [ ] Row has correct phone
- [ ] Row has correct lead ID
- [ ] Row has correct trigger type
- [ ] Row has correct source page
- [ ] Row has correct lead source
- [ ] Row updated in Google Sheets (Step 2)
- [ ] Row has correct email
- [ ] Row has correct notes
- [ ] Row has correct call preference

### UTM Tracking
- [ ] UTM parameters captured from URL
- [ ] UTM data passed to API
- [ ] UTM data synced to HubSpot
- [ ] Lead source detected correctly
- [ ] UTM validation works (prevents stale cookie submission)

## Error Handling Testing

### Network Errors
- [ ] Form handles network timeout (15s)
- [ ] Error message displays on timeout
- [ ] Form can be resubmitted after error
- [ ] Loading state clears on error

### Validation Errors
- [ ] Name required validation works
- [ ] Phone required validation works
- [ ] Phone format validation works
- [ ] Email format validation works (if provided)
- [ ] Error messages display correctly
- [ ] Error styling applied to inputs

### API Errors
- [ ] HubSpot API failure handled gracefully
- [ ] Google Sheets API failure handled gracefully
- [ ] Error logged to log files
- [ ] User sees friendly error message
- [ ] Form can be resubmitted after error

## Session Management Testing

### Submission Tracking
- [ ] Form submission tracked in sessionStorage
- [ ] Form submission tracked in localStorage
- [ ] 30-day expiration set correctly
- [ ] Popup doesn't appear after submission (within 30 days)
- [ ] Popup appears after expiration (after 30 days)

### Page State
- [ ] Popup only shows once per page
- [ ] State resets on page navigation
- [ ] State persists on page refresh (until cleared)
- [ ] Refresh detection works correctly

## Cross-Browser Testing

### Desktop Browsers
- [ ] Chrome (latest)
- [ ] Firefox (latest)
- [ ] Safari (latest)
- [ ] Edge (latest)

### Mobile Browsers
- [ ] iOS Safari
- [ ] Chrome Mobile
- [ ] Samsung Internet

### Browser Features
- [ ] Popup displays correctly
- [ ] Form submission works
- [ ] Triggers work correctly
- [ ] Mobile exit intent works (rapid scroll up)
- [ ] Desktop exit intent works (mouse leave)

## Mobile Testing

### Responsiveness
- [ ] Popup displays correctly on mobile
- [ ] Form fields are touch-friendly (44x44px minimum)
- [ ] Text is readable (no zoom required)
- [ ] Buttons are easily tappable
- [ ] Form doesn't cause layout shift

### Mobile-Specific Features
- [ ] Mobile exit intent works (rapid scroll up)
- [ ] Keyboard doesn't cover form fields
- [ ] Form submission works on mobile
- [ ] Phone number input shows numeric keyboard

## Accessibility Testing

### Keyboard Navigation
- [ ] Tab key navigates through form fields
- [ ] Enter key submits form
- [ ] ESC key closes popup
- [ ] Focus visible on all interactive elements
- [ ] Focus order is logical

### Screen Reader
- [ ] ARIA labels present
- [ ] Form fields have labels
- [ ] Error messages announced
- [ ] Success message announced
- [ ] Popup state announced

### Visual Accessibility
- [ ] Color contrast meets WCAG AA (4.5:1)
- [ ] Error states visible without color
- [ ] Focus indicators visible
- [ ] Text is readable (16px minimum on mobile)

## Performance Testing

### Load Time
- [ ] Popup component loads quickly
- [ ] Trigger script loads quickly
- [ ] No performance impact on page load
- [ ] Copy detection is fast (<10ms)

### Runtime Performance
- [ ] Scroll listener doesn't cause lag
- [ ] Form submission is responsive
- [ ] No memory leaks
- [ ] No console errors

## Copy Testing

### Copy Detection
- [ ] Correct headline displays
- [ ] Correct description displays
- [ ] Copy matches page type
- [ ] Default copy shows if no match

### Copy Quality
- [ ] Headline uses du tone (informal)
- [ ] Description uses du tone
- [ ] Copy is relevant to page
- [ ] Copy includes benefit
- [ ] Copy includes CTA

## Trigger Testing

### Time Trigger
- [ ] Triggers after correct delay (30-60s)
- [ ] Only triggers once
- [ ] Respects page priority

### Scroll Trigger
- [ ] Triggers at correct threshold (25-40%)
- [ ] Only triggers once
- [ ] Respects page type

### Exit Intent Trigger
- [ ] Desktop: Triggers on mouse leave
- [ ] Mobile: Triggers on rapid scroll up
- [ ] Respects minimum time requirement
- [ ] Respects minimum scroll requirement
- [ ] Only triggers once

### Manual Trigger
- [ ] `window.leadCapturePopup.show('manual')` works
- [ ] `window.leadCapturePopup.show('manual-callback')` works
- [ ] Manual trigger bypasses restrictions (if callback)

## Edge Cases

### Special Pages
- [ ] ShiftOps report (gated content) - triggers only after unlock
- [ ] Blog posts - optimized triggers work
- [ ] Tools pages - longer delay works
- [ ] Comparison pages - lower scroll threshold works

### User Scenarios
- [ ] User closes popup without submitting
- [ ] User submits Step 1 but closes before Step 2
- [ ] User refreshes page after Step 1
- [ ] User navigates away after Step 1
- [ ] User submits form multiple times (should be blocked)

## Post-Deployment Monitoring

### Log Monitoring
- [ ] Check `v2/logs/lead-capture.log` for errors
- [ ] Check `v2/logs/lead-capture-debug.log` for errors
- [ ] Monitor HubSpot API errors
- [ ] Monitor Google Sheets API errors

### Analytics
- [ ] Track popup appearances
- [ ] Track form submissions
- [ ] Track conversion rate
- [ ] Track trigger performance

## Quick Test Commands

### Browser Console
```javascript
// Check popup status
window.leadCapturePopup?.isOpen();

// Manually show popup
window.leadCapturePopup?.show('manual');

// Reset state
window.resetLeadCapture();

// Check trigger status
console.log(window.leadCaptureTriggers?.hasShown);
```

### Server Logs
```bash
# Monitor logs in real-time
tail -f v2/logs/lead-capture-debug.log

# Search for errors
grep -i "error" v2/logs/lead-capture-debug.log

# Search for specific lead ID
grep "LC1234567890" v2/logs/lead-capture-debug.log
```

### API Testing
```bash
# Test HubSpot connectivity
curl "http://localhost:8003/v2/api/lead-capture.php?debug_hubspot=test"

# Test form submission
curl -X POST http://localhost:8003/v2/api/lead-capture.php \
  -H "Content-Type: application/json" \
  -d '{"step":"1","name":"Test","phone":"+49123456789"}'
```

## Related Documentation

- [Architecture Overview](./ARCHITECTURE.md) - System architecture
- [Integration Guide](./INTEGRATION_GUIDE.md) - Adding popup to pages
- [Trigger Configuration](./TRIGGER_CONFIGURATION.md) - Trigger setup
- [Copy Management](./COPY_MANAGEMENT.md) - Copy configuration
- [Troubleshooting Guide](./TROUBLESHOOTING.md) - Common issues

