Answer the question
In order to leave comments, you need to log in
How to correctly set the goal of a metric / analytics using js?
Tell me please. How to set a goal so that it works.
The site has feedback forms, I'm trying to add onsubmit through the script, but for some reason it is not attached to the form. On the button via onclick is not an option, since there are no unique classes
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#yw1').attr("onsubmit","yaCounter46372170.reachGoal('zakazbistr'); gtag('send', 'event', { 'event_category': 'sub', 'event_action': 'btnsub'}); return true;");
});
</script>
Answer the question
In order to leave comments, you need to log in
Why are you using the .attr() method? It's easier to do this:
jQuery(document).ready(function(){
jQuery('#yw1').on("submit", function() {
yaCounter46372170.reachGoal('zakazbistr');
gtag('send', 'event', { 'event_category': 'sub', 'event_action': 'btnsub'});
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question