@novikoff82

Как победить цель метрики на кнопку?

Всем привет!
Я совсем не программист, насмотрелся видео по настройке целей метрики.
На сайте есть всего 3 кнопки: 2 победил, 1 не сдается.
Все делал по букварю, но статистика не приходит.
Подскажите, что не так...

Спасибо.

<?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>
  • Вопрос задан
  • 188 просмотров
Пригласить эксперта
Ответы на вопрос 1
@marxxt
понравился ответ - поставь ✔
<form action="">
    ...
    <input type="button" onclick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" value="Заказать" />
</form>

https://yandex.ru/support/metrika/objects/reachgoa...
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы