# UTM Cleanup Deployment Checklist

**Last Updated:** 2026-01-29

## Pre-Deployment Checklist

### Code Review ✅

- [x] Code changes reviewed
- [x] No linter errors
- [x] Minification successful
- [x] Feature flag tested
- [x] Test scripts created

### Testing ✅

- [x] Analytics timing verified
- [x] Form tracking tested
- [x] Link sharing scenarios tested
- [x] Performance measured
- [x] Browser compatibility verified

### Documentation ✅

- [x] Analysis complete
- [x] Recommendation documented
- [x] Improvements documented
- [x] Monitoring setup documented
- [x] Rollback plan documented

## Deployment Steps

### Step 1: Backup Current Code

```bash
# Create backup branch
git checkout -b backup/pre-utm-cleanup-improvements
git push origin backup/pre-utm-cleanup-improvements

# Return to main branch
git checkout master
```

### Step 2: Deploy Code Changes

```bash
# Commit changes
git add v2/js/utm-tracking.js
git add v2/js/utm-cleanup-feature-flag.js
git add v2/base/head.php
git add v2/js/utm-tracking.min.js
git commit -m "Improve UTM cleanup: feature flag, better timing, monitoring"

# Deploy to production
git push origin master
```

### Step 3: Verify Deployment

1. **Check Files Deployed:**
   - Verify `utm-tracking.min.js` updated
   - Verify `utm-cleanup-feature-flag.js` exists
   - Verify `head.php` includes feature flag

2. **Test Feature Flag:**

   ```javascript
   // In browser console
   localStorage.setItem("utmCleanupEnabled", "false");
   window.location.reload();
   // Verify cleanup disabled
   ```

3. **Test Cleanup:**
   - Visit page with UTMs
   - Verify cleanup executes
   - Check console for events
   - Verify UTMs removed from URL

### Step 4: Set Up Monitoring

1. **GTM Configuration:**
   - Follow `docs/monitoring/UTM_CLEANUP_MONITORING_SETUP.md`
   - Create variables
   - Create triggers
   - Create tags
   - Publish changes

2. **GA4 Configuration:**
   - Create custom dimensions (optional)
   - Create exploration report
   - Create alerts
   - Set up dashboard

3. **Verify Monitoring:**
   - Check GTM Preview Mode
   - Verify events in dataLayer
   - Check GA4 Real-Time reports
   - Verify alerts configured

### Step 5: Monitor Initial Deployment

**First 24 Hours:**

- [ ] Monitor cleanup success rate
- [ ] Check for errors
- [ ] Verify analytics capture
- [ ] Monitor form tracking
- [ ] Check performance impact

**First Week:**

- [ ] Monitor daily success rates
- [ ] Check error trends
- [ ] Verify analytics data quality
- [ ] Monitor form attribution
- [ ] Collect user feedback

## Post-Deployment Validation

### Success Criteria

- [ ] Cleanup success rate > 95%
- [ ] Error rate < 5%
- [ ] Average duration < 50ms
- [ ] Analytics capture working
- [ ] Form tracking working
- [ ] No performance degradation
- [ ] No user complaints

### Validation Tests

1. **Analytics Capture:**
   - Visit page with UTMs
   - Verify GTM/GA4 capture UTMs
   - Verify HubSpot capture UTMs
   - Check cleanup executes after capture

2. **Form Tracking:**
   - Submit demo booking form
   - Verify UTM data in form fields
   - Check HubSpot contact record
   - Verify attribution correct

3. **Link Sharing:**
   - Copy URL after cleanup
   - Verify UTMs removed
   - Share link via email
   - Verify no misattribution

4. **Performance:**
   - Measure page load time
   - Measure cleanup duration
   - Verify no degradation
   - Check browser compatibility

## Rollback Procedures

### Quick Rollback (Feature Flag)

```javascript
// Disable cleanup immediately
localStorage.setItem("utmCleanupEnabled", "false");
window.location.reload();
```

### Full Rollback (Code)

```bash
# Revert to backup branch
git checkout backup/pre-utm-cleanup-improvements
git push origin master --force
```

### Rollback Triggers

- Cleanup success rate < 90%
- Error rate > 10%
- Analytics capture failures > 5%
- Form tracking failures > 5%
- Performance degradation > 20%
- User complaints

## Monitoring Schedule

### Daily (First Week)

- Check cleanup success rate
- Review error logs
- Verify analytics capture
- Check form attribution

### Weekly (First Month)

- Review success rate trends
- Analyze error patterns
- Optimize timing if needed
- Update documentation

### Monthly (Ongoing)

- Review overall performance
- Analyze misattribution incidents
- Optimize based on data
- Update best practices

## Related Documentation

- [`UTM_CLEANUP_FINAL_RECOMMENDATION.md`](../archive/2026-04-01-docs-cleanup/utm-cleanup-analysis/UTM_CLEANUP_FINAL_RECOMMENDATION.md) — Final recommendation (archived analysis)
- `docs/monitoring/UTM_CLEANUP_MONITORING_SETUP.md` - Monitoring setup
- `docs/monitoring/UTM_CLEANUP_ALERTS_CONFIGURATION.md` - Alerts configuration
- [`UTM_CLEANUP_ROLLBACK_PLAN.md`](../archive/2026-04-01-docs-cleanup/utm-cleanup-analysis/UTM_CLEANUP_ROLLBACK_PLAN.md) — Rollback plan (archived analysis)
