Answer the question
In order to leave comments, you need to log in
How to defeat the target metrics per button?
Hello!
I'm not a programmer at all, I've seen enough videos on setting metric goals.
There are only 3 buttons on the site: 2 won, 1 does not give up.
I did everything according to the primer, but the statistics do not come.
Tell me what's wrong ...
Thank you.
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true ) die();?>
<div class="feedback-wrapper">
<div class="container">
<div class="row feedback">
<div class="col-md-12">
<div class="h1"><?=$arResult["IBLOCK_NAME"]?></div>
</div>
<form id="<?=$arResult['IBLOCK_CODE']?>_form" action="javascript:void(0)">
<div class="col-md-12">
<div id="<?=$arResult['IBLOCK_CODE']?>_alert" class="alert" style="display:none;"></div>
</div>
<input type="hidden" name="IBLOCK_CODE" value="<?=$arResult['IBLOCK_CODE']?>" />
<input type="hidden" name="IBLOCK_NAME" value="<?=$arResult['IBLOCK_NAME']?>" />
<input type="hidden" name="IBLOCK_ID" value="<?=$arParams['IBLOCK_ID']?>" />
<input type="hidden" name="USE_CAPTCHA" value="<?=$arParams['USE_CAPTCHA']?>" />
<?if(is_array($arResult["FIELDS"])):?>
<input type="hidden" name="FIELDS_STRING" value="<?=$arResult['FIELDS_STRING']?>" />
<div class="col-md-3">
<?foreach($arResult["FIELDS"] as $key => $arField):
if($arField["USER_TYPE"] != "HTML"):?>
<div class="form-group<?=(!empty($arField['HINT']) ? ' has-feedback' : '');?>">
<input type="text" name="<?=$arField['CODE']?>" class="form-control" placeholder="<?=$arField['NAME']?>" />
<?if(!empty($arField["HINT"])):?>
<i class="form-control-feedback fv-icon-no-has fa <?=$arField['HINT']?>"></i>
<?endif;?>
</div>
<?endif;
endforeach;?>
</div>
<div class="col-md-6">
<?foreach($arResult["FIELDS"] as $key => $arField):
if($arField["USER_TYPE"] == "HTML"):?>
<div class="form-group<?=(!empty($arField['HINT']) ? ' has-feedback' : '');?>">
<textarea name="<?=$arField['CODE']?>" class="form-control" rows="3" placeholder="<?=$arField['NAME']?>" style="height:<?=$arField['USER_TYPE_SETTINGS']['height']?>px; min-height:<?=$arField['USER_TYPE_SETTINGS']['height']?>px; max-height:<?=$arField['USER_TYPE_SETTINGS']['height']?>px;"></textarea>
<?if(!empty($arField["HINT"])):?>
<i class="form-control-feedback fv-icon-no-has fa <?=$arField['HINT']?>"></i>
<?endif;?>
</div>
<?endif;
endforeach;?>
</div>
<?endif;?>
<div class="col-md-3">
<?if($arParams["USE_CAPTCHA"] == "Y"):
$frame = $this->createFrame()->begin("");?>
<div class="form-group captcha">
<div class="pic">
<img src="/bitrix/tools/captcha.php?captcha_sid=<?=$arResult['CAPTCHA_CODE']?>" width="100" height="36" alt="CAPTCHA" />
</div>
<input type="text" maxlength="5" name="CAPTCHA_WORD" class="form-control" placeholder="<?=GetMessage('FORMS_FEEDBACK_CAPTCHA_WORD')?>" />
<input type="hidden" name="CAPTCHA_SID" value="<?=$arResult['CAPTCHA_CODE']?>" />
</div>
<?$frame->end();
endif;?>
<div class="form-group<?=($arParams["USE_CAPTCHA"] == "N" ? ' no-captcha' : '');?>">
<button onClick="yaCounterХХХХХ.reachGoal('zak_zv'); return true;" type="submit" class="btn btn-primary"><?=GetMessage("FORMS_FEEDBACK_SUBMIT")?></button>
</div>
</div>
<?if($arParams["USER_CONSENT"] == "Y"):?>
<input type="hidden" name="USER_CONSENT_ID" value="<?=$arParams['USER_CONSENT_ID']?>" />
<input type="hidden" name="URL" value="<?=$APPLICATION->GetCurPage()?>" />
<div class="col-md-12">
<div class="form-group form-group-checkbox">
<div class="checkbox">
<?$fields = array();
if(is_array($arResult["FIELDS"])):
foreach($arResult["FIELDS"] as $key => $arField):
if($arField["USER_TYPE"] != "HTML"):
$fields[] = $arField["NAME"];
endif;
endforeach;
endif;?>
<?$APPLICATION->IncludeComponent("bitrix:main.userconsent.request", "",
array(
"ID" => $arParams["USER_CONSENT_ID"],
"INPUT_NAME" => "USER_CONSENT",
"IS_CHECKED" => $arParams["USER_CONSENT_IS_CHECKED"],
"AUTO_SAVE" => "N",
"IS_LOADED" => $arParams["USER_CONSENT_IS_LOADED"],
"REPLACE" => array(
"button_caption" => GetMessage("FORMS_FEEDBACK_SUBMIT"),
"fields" => $fields
)
),
$component
);?>
<?unset($fields);?>
</div>
</div>
</div>
<?endif;?>
</form>
</div>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
$(function() {
var form = BX("<?=$arResult['IBLOCK_CODE']?>_form"),
alert = BX("<?=$arResult['IBLOCK_CODE']?>_alert");
<?if($arParams["USE_CAPTCHA"] == "Y"):?>
var captchaImg = form.querySelector("[alt='CAPTCHA']"),
captchaWord = form.querySelector("[name='CAPTCHA_WORD']"),
captchaSid = form.querySelector("[name='CAPTCHA_SID']");
<?endif;?>
//MASK//
<?if(is_array($arResult["FIELDS"])):
foreach($arResult["FIELDS"] as $key => $arField):
if($arField["CODE"] == "PHONE" && !empty($arResult["SETTINGS"]["PHONE_MASK"]["VALUE"])):?>
var inputPhone = form.querySelector("[name='<?=$arField['CODE']?>']");
$(inputPhone).inputmask("<?=$arResult['SETTINGS']['PHONE_MASK']['VALUE']?>");
<?endif;
endforeach;
endif;?>
//VALIDATION//
$(form).formValidation({
framework: "bootstrap",
icon: {
valid: "fa fa-check",
invalid: "fa fa-times",
validating: "fa fa-refresh"
},
fields: {
<?if(is_array($arResult["FIELDS"])):
foreach($arResult["FIELDS"] as $key => $arField):?>
<?=$arField["CODE"]?>: {
row: ".form-group",
validators: {
<?if($arField["IS_REQUIRED"] == "Y"):?>
notEmpty: {
message: "<?=GetMessage('FORMS_FEEDBACK_NOT_EMPTY_INVALID')?>"
},
<?endif;
if($arField["CODE"] == "PHONE" && !empty($arResult["SETTINGS"]["VALIDATE_PHONE_MASK"]["VALUE"])):?>
regexp: {
message: "<?=GetMessage('FORMS_FEEDBACK_REGEXP_INVALID')?>",
regexp: /<?=$arResult["SETTINGS"]["VALIDATE_PHONE_MASK"]["VALUE"]?>/
},
<?endif;?>
}
},
<?endforeach;
endif;
if($arParams["USE_CAPTCHA"] == "Y"):?>
CAPTCHA_WORD: {
row: ".form-group",
validators: {
notEmpty: {
message: "<?=GetMessage('FORMS_FEEDBACK_NOT_EMPTY_INVALID')?>"
},
remote: {
type: "POST",
url: "<?=$componentPath?>/captcha.php",
message: "<?=GetMessage('FORMS_FEEDBACK_CAPTCHA_WRONG')?>",
data: function() {
return {
CAPTCHA_SID: captchaSid.value
};
},
delay: 1000
}
}
},
<?endif;
if($arParams["USER_CONSENT"] == "Y"):?>
USER_CONSENT: {
row: ".form-group",
validators: {
notEmpty: {
message: "<?=GetMessage('FORMS_FEEDBACK_USER_CONSENT_NOT_EMPTY_INVALID')?>"
}
}
}
<?endif;?>
}
});
//REVALIDATION//
<?if($arParams["USER_CONSENT"] == "Y"):?>
BX.addCustomEvent(form, "OnFormInputUserConsentChange", function() {
$(form).formValidation("revalidateField", "USER_CONSENT");
});
<?endif;?>
//SEND_FORM//
$(form).on("success.form.fv", function(e) {
e.preventDefault();
var $form = $(e.target);
//AJAX//
$.ajax({
url: "<?=$componentPath?>/script.php",
type: "POST",
data: $form.serialize(),
dataType: "json",
success: function(response) {
//CLEAR_FORM//
$form.formValidation("resetForm", true);
//SHOW_MESSAGE//
if(!!response.result) {
if(response.result == "Y") {
BX.adjust(alert, {
props: {
className: "alert alert-success"
},
style: {
display: "block"
},
html: "<?=GetMessage('FORMS_FEEDBACK_ALERT_SUCCESS')?>"
});
} else {
BX.adjust(alert, {
props: {
className: "alert alert-warning"
},
style: {
display: "block"
},
html: "<?=GetMessage('FORMS_FEEDBACK_ALERT_WARNING')?>"
});
}
}
//CAPTCHA//
<?if($arParams["USE_CAPTCHA"] == "Y"):?>
if(!!response.captcha_code) {
BX.adjust(captchaImg, {
attrs: {
src: "/bitrix/tools/captcha.php?captcha_sid=" + response.captcha_code
}
});
captchaWord.value = "";
captchaSid.value = response.captcha_code;
}
<?endif;?>
}
});
});
});
//]]>
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question