Untitled
unknown
php
2 years ago
1.1 kB
3
Indexable
Never
/*Добавление yclid в amocrm*/ function catch_yclient_id() { ?> <script> function setCookie(name, value, days){ var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); var expires = "; expires=" + date.toGMTString(); document.cookie = name + "=" + value + expires + ";path=/"; } function getParam(p){ var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search); return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); } var yclid = getParam('yclid'); if(yclid){ setCookie('yclid', yclid, 90); } </script> <?php } add_action('wp_print_scripts', 'catch_yclient_id'); function add_yclid_to_amo($fields, $order) { $yclid_field_id = '904771'; if (!empty($_COOKIE['yclid'])) { $fields[ $yclid_field_id] = $_COOKIE['yclid']; } else { $fields[ $yclid_field_id] = ''; } return $fields; } add_filter('itglx_wcamo_lead_fields', 'add_yclid_to_amo', 10, 2);