$postData = [
'TITLE' => 'Заявка с сайта ' . $url,
'NAME' => $name,
'PHONE_MOBILE' => $phone,
'COMMENTS' => 'Источник заявки: ' . $source,
'UTM_CAMPAIGN' => 'campaign',
'UTM_CONTENT' => 'content',
'UTM_MEDIUM' => 'medium',
'UTM_SOURCE' => 'source',
'UTM_TERM' => 'term',
];
if(isset($_GET["utm_source"])) setcookie("utm_source",$_GET["utm_source"],time()+3600*24*30,"/");
if(isset($_GET["utm_medium"])) setcookie("utm_medium",$_GET["utm_medium"],time()+3600*24*30,"/");
if(isset($_GET["utm_campaign"])) setcookie("utm_campaign",$_GET["utm_campaign"],time()+3600*24*30,"/");
if(isset($_GET["utm_content"])) setcookie("utm_content",$_GET["utm_content"],time()+3600*24*30,"/");
if(isset($_GET["utm_term"])) setcookie("utm_term",$_GET["utm_term"],time()+3600*24*30,"/");
<input name="utm-source" type="hidden" value="<?=$_COOKIE['utm_source']?>">
<input name="utm-medium" type="hidden" value="<?=$_COOKIE['utm_medium']?>">
<input name="utm-compaign" type="hidden" value="<?=$_COOKIE['utm_compaign']?>">
<input name="utm-content" type="hidden" value="<?=$_COOKIE['utm_content']?>">
<input name="utm-term" type="hidden" value="<?=$_COOKIE['utm_term']?>">
'UTM_SOURCE' => $_POST['utm-source'],
'UTM_MEDIUM' => $_POST['utm-medium'],
'UTM_CAMPAIGN' => $_POST['utm-campaign'],
'UTM_CONTENT' => $_POST['utm-content'],
'UTM_TERM' => $_POST['utm-term'],
if(isset($_GET["utm_source"])) setcookie("utm_source",$_GET["utm_source"],time()+3600*24*30,"/");
if(isset($_GET["utm_medium"])) setcookie("utm_medium",$_GET["utm_medium"],time()+3600*24*30,"/");
if(isset($_GET["utm_campaign"])) setcookie("utm_campaign",$_GET["utm_campaign"],time()+3600*24*30,"/");
if(isset($_GET["utm_content"])) setcookie("utm_content",$_GET["utm_content"],time()+3600*24*30,"/");
if(isset($_GET["utm_term"])) setcookie("utm_term",$_GET["utm_term"],time()+3600*24*30,"/");
if(isset($_COOKIE["utm_source"]) and !isset($_GET["utm_source"])) $_GET["utm_source"] = $_COOKIE["utm_source"];
if(isset($_COOKIE["utm_medium"]) and !isset($_GET["utm_medium"])) $_GET["utm_medium"] = $_COOKIE["utm_medium"];
if(isset($_COOKIE["utm_campaign"]) and !isset($_GET["utm_campaign"])) $_GET["utm_campaign"] = $_COOKIE["utm_campaign"];
if(isset($_COOKIE["utm_content"]) and !isset($_GET["utm_content"])) $_GET["utm_content"] = $_COOKIE["utm_content"];
if(isset($_COOKIE["utm_term"]) and !isset($_GET["utm_term"])) $_GET["utm_term"] = $_COOKIE["utm_term"];
update_bitrix_entity('deal', 13,array('UTM_SOURCE' =>'NEW'));
function update_bitrix_entity($entity, $id, $fiels = array())
{
if (!in_array($entity, array('lead', 'deal', 'contact', 'company')))
{
return false;
}
$name = "crm.{$entity}.update";
$post = array(
'id' => $id,
'fields' => $fiels);
$ret = bitrix::call($name, $post);
return $ret;
}