Answer the question
In order to leave comments, you need to log in
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><?
}
}
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question