Есть гугл цель на JS
gtag('event', 'click_button_callback', { 'event_category': 'zakaz-zvonka', 'event_action': 'zakaz-zvonka', });
Вся проверка и отправка формы построена на PHP, как при удачной отправке формы отправить цель gtag?
if($this->request->method('post') && $this->request->post('callback')) {
$callback = new stdClass();
$callback->phone = $this->request->post('phone');
$callback->name = $this->request->post('name');
$callback->url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$callback->message = $this->request->post('message');
$captcha_code = $this->request->post('captcha_code', 'string');
$this->design->assign('callname', $callback->name);
$this->design->assign('callphone', $callback->phone);
$this->design->assign('callmessage', $callback->message);
/*Валидация данных клиента*/
if (!$this->validate->is_name($callback->name, true)) {
$this->design->assign('call_error', 'empty_name');
} elseif(!$this->validate->is_phone($callback->phone, true)) {
$this->design->assign('call_error', 'empty_phone');
} elseif(!$this->validate->is_comment($callback->message)) {
$this->design->assign('call_error', 'empty_comment');
} elseif($this->settings->captcha_callback && !$this->validate->verify_captcha('captcha_callback', $captcha_code)) {
$this->design->assign('call_error', 'captcha');
} elseif($callback_id = $this->callbacks->add_callback($callback)) {
$this->design->assign('call_sent', true);
//Уведомим в Telegram
if($this->settings->tg_notify==1)
$this->telegram_notify->sendMessageAboutСallback($callback->name, $callback->phone, 'форма заказа обратного звонка');
// Отправляем email
$this->notify->email_callback_admin($callback_id);
} else {
$this->design->assign('call_error', 'unknown error');
}
}