menu

arrow_back How best to arrange the transfer of indiicator purpose of ajax forms in modx metric?

by
0 votes
How best to organize the sending of indiicator purpose of yaCounterXXXXXX.reachGoal('TARGET_NAME') ?
If you put on a onclick event or onsubmit, that dispatch occurs regardless of whether the correct user has filled the form or not. Now I made a function call in yaCounterXXXXXX %26successMessage. But I would like a more aesthetic solution. Thanks in advance.
[[!AjaxForm?
&snippet=`FormIt`
&form=`tplzabr`
&hooks=`email`
&emailSubject=`*********`
&emailTo=`*********`
&validate=`ФИО:required, Телефон:required, E-mail:required`
&validationErrorMessage=`В форме содержатся ошибки!`
&successMessage=`Сообщение успешно отправлено <script>yaCounter********.reachGoal('ZABRONIR');</script>`
]]

1 Answer

by
 
Best answer
0 votes
$(document).on('af_complete', function(event, response) {
var form = response.form;
if (response.success) {
yaCounter********.reachGoal('ZABRONIR');
}
});