private function addUTM($html, $subject)
{
// match links
$matches = array();
preg_match_all('/href="(http:\\/\\/(.*))"/iU', $html, $matches);
// any links?
$utm = array('utm_source' => 'mail', 'utm_medium' => 'email', 'utm_campaign' => Uri::getUrl($subject));
if (isset($matches[0]) && !empty($matches[0])) {
$searchLinks = array();
$replaceLinks = array();
// loop old links
foreach ($matches[1] as $i => $link) {
$searchLinks[] = $matches[0][$i];
$replaceLinks[] = 'href="' . Model::addURLParameters($link, $utm) . '"';
}
$html = str_replace($searchLinks, $replaceLinks, $html);
}
return $html;
}