A
A
Andrey Dontsov2018-09-18 20:44:15
JavaScript
Andrey Dontsov, 2018-09-18 20:44:15

Simultaneous targets (js events) for metrics and google analytics?

Greetings, dear ones!
How are js events of a click on a button (goal) set up simultaneously for YaMetrika and Google Analytics?
For example, now the button has the following code:

<button id="mail_submit" onclick="yaCounter99999999.reachGoal('mail_submit'); return true;">Submit</button>

If you add another onclick attribute to the same tag, that won't work, and that's wrong, right?
How are button click events configured simultaneously for both metrics, both google and Yandex?
It turns out in separate scripts? Can I have an example?
Something like this?
document.getElementById("mail_submit").addEventListener("click", function(){
    yaCounter99999999.reachGoal('mail_submit');
    ga("send", "event", "mail_submit", "click");
    //если инлайн код для гугла onclick="ga (‘send', ‘event', ‘mail_submit', ‘click'); return true;"
});

Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question