Where to paste the code purpose Yandex.Metrics?

Can't understand where to insert the code purpose Yandex.Metrics in the form?

Form code
<form class="form_popup" method="POST"> 

 <input type="text" required placeholder="Enter name" class="name2" name="Name">
 <input id="phone2" type="text" required placeholder="Enter phone" class="name2" name="Phone"> 
 <input type="submit" class="main-button2" value="Send">
 </form>


And here is the code which is sent to be inserted on the website
on_submit="try { ga ('send', 'event', 'click', 'otpravka');}catch(exc) {console.dir(exc);} try{yaCounter47377579.reachGoal('otpravka');} catch(exc) {console.dir(exc);}
June 8th 19 at 16:45
1 answer
June 8th 19 at 16:47
If the form onsubmit
<form class="form_popup" method="POST" onsubmit="try { ga ('send', 'event', 'click', 'otpravka');}catch(exc) {console.dir(exc);} try{yaCounter47377579.reachGoal('otpravka');} catch(exc) {console.dir(exc);}> 
 <input type=" text" required placeholder="Enter name" name="Name">
 <input id="phone2" type="text" required placeholder="Enter phone" class="name2" name="Phone"> 
 <input type="submit" class="main-button2" value="Send">
 </form>

Find more questions by tags Yandex.MetricaYandex.Direct