<a class="like" href="site1=site2" onclick="ga('send', 'event', 'outbound', 'click', 'google.ru/music_save/');metrika_goal('music_save');">схранить трек</a>
require_once 'phpQuery/phpQuery/phpQuery.php';
$html = file_get_contents('https://ссылка_на_страницу');
$doc = phpQuery::newDocument($html);
$link = $doc->find('селектор_для_поиска_ссылки');
pq($link)->attr('href', 'https://новый_адрес_для_ссылки');
echo pq($doc)->html();
<?php
$str = "<a class=\"like\" href=\"site1=site2\" onclick=\"ga('send', 'event', 'outbound', 'click', 'google.ru/music_save/');metrika_goal('music_save');\">сохранить трек</a>";
echo ChangeHref($str, 'like' ,'https://www.google.com/');
function ChangeHref($str, $class, $link){
return preg_replace('#(<a[^>]*class="[^"]*'.$class.'[^"]*"[^>]*href=")([^>])*("[^>]*>)#', "$1". $link. "$3", $str);
}
?>
$custom_value
передаете новое значение для ссылки. Измененный текст у вас по прежнему в переменной $html$html = file_get_html($file_path);
// получаем ссылку
$link = $html->find( 'a.like', 0 );
$link->href = $custom_value;
$html->clear();
unset($html);