V
V
Vadim Timoshenko2019-03-18 17:02:55
1C-Bitrix
Vadim Timoshenko, 2019-03-18 17:02:55

How to correctly set a goal for a submitted web form in 1C-Bitrix?

I found a solution on the Bitrix forum:
1) customize the form.result.new component in our namespace
2) add the code in the component.php file

if (!empty($_REQUEST["formresult"]) && $_REQUEST['WEB_FORM_ID'] == $arParams['WEB_FORM_ID'])
      {
         $formResult = strtoupper($_REQUEST['formresult']);
         switch ($formResult)
         {
            case 'ADDOK':
               $arResult['FORM_NOTE'] = str_replace("#RESULT_ID#", $RESULT_ID, GetMessage('FORM_NOTE_ADDOK'));
               if($_REQUEST['WEB_FORM_ID'] == "1"){
                  ?><sc ript>yaCounterXXXXXXXX.reachGoal("send_question");</sc ript><?
               } else if($_REQUEST['WEB_FORM_ID'] == "4"){
                  ?><sc ript>$(document).ready(function(){yaCounterXXXXXXXX.reachGoal("send_bron");})</sc ript><?
               }
         }

      }

I am not familiar with Bitrix. And the phrase "namespace" causes me brain difficulties)) I found that it is ( https://dev.1c-bitrix.ru/learning/course/index.php... but I still can't get into it quickly
. I found public_html/bitrix/components/bitrix/form.result.new/ and /public_html/bitrix/components/bitrix/form.result.new/component.php file. please on the fingers (step by step) what I need to do
ps: I can insert onsubmit into the form template, but such goals do not suit me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
2cha.headz, 2019-03-19
@PbI6A_KuT

to customize a component, you need to add its copy to the folder:
/local/components/NAMESPACE/COMPONENT_NAME/
NAMESPACE, you can specify your own (for example, namespase), or don’t worry and write bitrix, but then all form.result.new components will be displayed customized,
i.e. . you need to copy the folder with the component /bitrix/components/bitrix/form.result.new/
to the folder /local/components/bitrix/form.result.new/
or to the folder /local/components/namespase/form.result.new/ (where namespace is your namespace)
and edit the component.php file there, then nothing will be lost on updates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question