Commit fdd3a912 authored by APolitsin's avatar APolitsin
Browse files

google-tag-event

parent a1bbc3bf
......@@ -25,9 +25,9 @@ class FormContactMessageFormAlter {
}
// Add ajax Callback.
if ($config->get('ya-counter') && $config->get('ya-goals')) {
if (isset($form['actions']['submit']['#ajax']['callback'])) {
$form['actions']['submit']['#ajax']['callback'] = $callback;
}
}
if (isset($form['actions']['submit']['#ajax']['callback'])) {
$form['actions']['submit']['#ajax']['callback'] = $callback;
}
// Preview.
if ($form_id == 'contact_message_order_form' && isset($form['field_form_zakaz']['widget'][0]['value'])) {
......@@ -87,20 +87,20 @@ class FormContactMessageFormAlter {
$goals[trim($exploded[1])] = trim($exploded[0]);
}
}
$debug = "";
$yandex = "";
$formId = $form['form_id']['#value'];
$google = "if (typeof dataLayer != 'undefined') {dataLayer.push({'event': '{$formId}'});}";
if (isset($goals[$formId])) {
$yandex = "";
$debug = "";
$google = "if (typeof dataLayer != 'undefined') {dataLayer.push({'event': '{$goals[$formId]}'});}";
if ($counter) {
$yandex = "yaCounter{$counter}.reachGoal('{$goals[$formId]}');";
}
if ($config->get('debug')) {
$debug = "console.log('{$formId}');";
}
$script = "<script type='text/javascript'>\n{$yandex} {$google} {$debug}\n</script>";
$response->addCommand(new HtmlCommand('#synapse-custom-ajax-cover', $script));
}
$script = "<script type='text/javascript'>\n{$yandex} {$google} {$debug}\n</script>";
$response->addCommand(new HtmlCommand('#synapse-custom-ajax-cover', $script));
}
return $response;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment