Several conditions in the onclick?

Good afternoon, prompt please, if the onclick event is in addition to the goal metric another condition, how to record it?

onclick="attrib='Find the cost';yaCounterXXXXX.reachGoal('name'); return true;"

tried it before, but the goal is not to work out.
March 23rd 20 at 18:54
2 answers
March 23rd 20 at 18:56
element.addEventListener('click', function() {
//code
});
March 23rd 20 at 18:58
Maybe You have already updated the Metric on the page?
Now the transmission of information for achieving the objective is available this code:
ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;
where XXXXXX is the number of your counter;
TARGET_NAME identifies a target.

Find more questions by tags Yandex.MetricaJavaScript