public function addCampaignParamsToAllUrls($html, $campaignParams)
    {
        $urlPattern = '/(href=[\'|"])(http[s]?\:\/\/\S*)([\'|"])/';

        $filteredHtml = preg_replace_callback($urlPattern, function ($matches) use ($campaignParams) {
            $start = $matches[1];
            $url = $matches[2];
            $end = $matches[3];
            $domain = parse_url($url, PHP_URL_HOST);

            // if the url is not in the list of domains to track then
            if (false === array_search($domain, $this->domainsToTrack)) {
                // don't append tracking parameters to the url
                return $start.$url.$end;
            }

            // avoid duplicate params and don't replace existing params
            $params = array();
            foreach ($campaignParams as $nextKey => $nextValue) {
                if (false === strpos($url, $nextKey)) {
                    $params[$nextKey] = $nextValue;
                }
            }

            $urlParams = http_build_query($params);

            if (false === strpos($url, '?')) {
                $urlParams = '?'.$urlParams;
            } else {
                $urlParams = '&'.$urlParams;
            }

            $replacement = $start.$url.$urlParams.$end;

            return $replacement;
        }, $html);

        return $filteredHtml;
    }