H
H
HelpSophie2019-06-21 17:16:45
JavaScript
HelpSophie, 2019-06-21 17:16:45

How to combine form validation and google analytics goals?

There is a form for sending feedback, which is checked by the script for validity (then on the server, of course, too).
Now they asked me to attach Google Analytics goals to the button

<button class="btn" type="submit"  onclick="ga ('send', 'event', 'catYYY', 'actionYYY'); return true;">Отправить</button>

Of course, at the same time, the verification script fell off.
How to bring it all together?
Then he will also want to redo the form submission to ajax, if this can suddenly change things.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
noeer, 2019-06-21
@HelpSophie

1. You have a syntax error
2. If you send asynchronously, then send the target after a successful response from the server. This way you will eliminate false positives if the data on the server does not pass validation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question