Answer the question
In order to leave comments, you need to log in
How to set goals for Yandex metrics on a button in react. Typescript swears?
There are targets for the event
and an example with a form and an input.
...
<form action="">
...
<input type="button" onclick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" value="Заказать" />
</form>
...
<Button onClick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME)" ></Button>
<Button onClick={()=> {
setCookie('startTime', +start);
props.setCountSubmit(props.countSubmit + 1);
setCookie('countSubmit', props.countSubmit);
props.setShowModalWindow(false);
props.setShowModalWindowThank(true);
postFormData(data}
}
></Button>
Answer the question
In order to leave comments, you need to log in
To everyone who came on the same issue, here is the solution -
You can call such functions with a callback using quotes
onClick={()=> `ym(XXXXXX, 'reachGoal', 'TARGET_NAME)`}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question