For example, suppose your goal is to recognize any CiviMail links going to `woogle.com` and
append code with the mailing ID (`&src=civimail_123`). Do this:
```php
if ($context['for'] === 'civicrm/mailing/url' && preg_match('/woogle\.com$/', $url->getHost())) {
$mailing_id = CRM_Core_DAO::singleValueQuery('
SELECT mj.mailing_id FROM civicrm_mailing_event_queue meq
INNER JOIN civicrm_mailing_job mj ON mj.id = meq.job_id
WHERE meq.id = %1
', [
1 => [$context['queue_id'], 'Int']
]);
$url = $url->withQuery($url->getQuery() . '&src=civimail_' . $mailing_id);
}
```
$url .= '#' . $pieces['fragment'];
}
}
- CRM_Utils_System::redirect($url);
+ CRM_Utils_System::redirect($url, [
+ 'for' => 'civicrm/mailing/url',
+ 'queue_id' => $queue_id,
+ 'url_id' => $url_id,
+ ]);
}
/**