# Trade Fair Lead Source Backfill Runbook

**Last Updated:** 2026-02-09

## Purpose

One-time (or occasional) backfill of HubSpot contacts that have `source__c` = "Trade Fair" (any current Lead Source), updating their Lead Source to "trade fair" for correct attribution.

## When to Run

- **One-time:** After deploying the event-lead-capture API fix that always sets `leadsource` to "trade fair" (to correct existing contacts created before the fix).
- **Optional future runs:** If new contacts appear with the same mismatch (e.g. from a different submission path).

## Prerequisites

- HubSpot API token: set `HUBSPOT_API_TOKEN` in the environment, or provide `v2/config/hubspot-api-key.php` with `return ['api_token' => 'pat-eu1-...'];`
- Script is run from CLI (e.g. terminal or cron); not for web.

## Command

```bash
# Dry-run: only search and log; no PATCH (recommended first)
php v2/scripts/hubspot/backfill-trade-fair-lead-source.php --dry-run

# Run updates
php v2/scripts/hubspot/backfill-trade-fair-lead-source.php
```

## Log Location

- Log file: `v2/logs/hubspot-trade-fair-lead-source-backfill-YYYY-MM-DD.log`
- Each run appends to the day’s log (contact ids, emails, success/failure, summary).

## Verification in HubSpot

1. In HubSpot, open Contacts.
2. Filter by Lead Source = "trade fair" and (if available) by property `source__c` = "Trade Fair".
3. Spot-check 3–5 contacts that were previously "Direct Traffic" to confirm Lead Source is now "trade fair".

## Related

- **API behavior:** [EVENT_FORM_IMPLEMENTATION.md](EVENT_FORM_IMPLEMENTATION.md) – event submissions always set `leadsource` to "trade fair".
- **Script:** `v2/scripts/hubspot/backfill-trade-fair-lead-source.php`
