D
D
Doremi7772018-08-07 16:33:55
1C-Bitrix
Doremi777, 2018-08-07 16:33:55

How to add the goal of Yandex Metrics and Google Analytics to the feedback form?

Hello!
I added goals to the button in the feedback form, but the statistics do not work. What can be wrong?

<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
?> 
<?=$arResult["FORM_HEADER"]?>
<div class="popup popup_feedback new_abonent<?if ($arResult["isFormNote"] == "Y"):?> popup_is-active<?endif;?>">

  <div class="popup__overlay"></div>

  <div class="popup__container container">
    <div class="popup__content">

      <div class="popup__close"></div>

      <?if ($arResult["isFormNote"] == "Y"):?>
        <div class="popup__title">
          <?=$arResult["FORM_NOTE"]?>
        </div>
        <script type="text/javascript">initPopups();</script> 
      <?else:?>
        <form id="<?=$arResult['arForm']['SID']?>" action="<?=$APPLICATION->GetCurPage()?>" method="POST" enctype="multipart/form-data">
        <div class="popup__title">
        Форма обратной связи
        </div>
        <div class="popup__wrapper">
        <div class="popup__wrap">
        <input class="popup__input input input_theme_grey-line input_fio" required="required" type="text" name="form_text_1" placeholder="ФИО*">
        <input class="popup__input input input_theme_grey-line input_phone" required="required" type="text" name="form_text_2" placeholder="Телефон*">
        <input class="popup__input input input_theme_grey-line" type="text" name="form_text_3" placeholder="Email">
        </div>
        <div class="popup__wrap">
        <input class="popup__input input input_theme_grey-line street" type="text" name="form_text_4" placeholder="Город и улица">
        <input class="popup__input input input_theme_grey-line home" type="text" name="form_text_5" placeholder="дом и квартира">
        <textarea class="popup__textarea textarea textarea_theme_grey-line" name="form_textarea_6" placeholder="Введите ваш комментарий"></textarea> <input type="hidden" name="form_hidden_7" class="selected_hidden_ultra_power"> <input type="hidden" name="form_hidden_8" class="monthly_pay"> <input type="hidden" name="form_hidden_9" class="equipment_pay"> <input type="hidden" name="form_hidden_10" class="final_pay"> <input type="hidden" name="form_hidden_11" class="adress_trtr"> <input type="hidden" name="form_hidden_12" value="<?=SITE_SERVER_NAME.'/'.$APPLICATION->GetCurPage()?>">
        </div>
        </div>
        <div class="popup__footer">
        <div class="popup__checkout">
        <div class="input input_checkbox input_theme_green-checkbox">
        <input class="input__source" required="required" type="checkbox" id="checkbox_deflt"> <label class="input__checkbox" for="checkbox_deflt"></label> <label class="input__text" for="checkbox_deflt">
        Я согласен с условиями подключения, а также даю согласие на обработку персональных данных согласно <?if(!empty($arResult['FILE_ID'])):?> <a class="input__text" target="blank" href="<?=$arResult['FILE']?>">Федеральному закону «О персональных данных»</a>
        <?else:?> Федеральному закону «О персональных данных» <?endif;?> </label>
        </div>
        </div>
        <button type="submit" id="submit_form_1" name="web_form_apply" ga ('send', 'event', 'goal', 'order');yaCounter******.reachGoal('form_submit');value="Отправить" class="button button_size_medium button_theme_full-green">Отправить</button>
        </div>
        </form>
      <?endif;?>
    </div>
  </div>

</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Kravchenko, 2018-08-07
@AntonKravchenko

shouldn't ga and YaCounter be inside onsubmit?

A
Alexander, 2018-08-07
Madzhugin @Suntechnic

What to aim for? On the fact of successful data acquisition?
Just for the fact of sending?
Apparently the result of sending is displayed here:

<?if ($arResult["isFormNote"] == "Y"):?>
        <div class="popup__title">
          <?=$arResult["FORM_NOTE"]?>
        </div>
        <script type="text/javascript">initPopups();</script> 
      <?else:?>

Means somewhere under this condition also it is necessary. Apparently, the author of the component did one cool thing - the output of errors and the output of a message about successful submission are not separated in any way. So you still need to add a condition there to check for success.
Well, if you do not care about receiving data from the form, but only tracking its submission, then onsubmit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question