W
W
WebforSelf2018-05-15 23:49:02
JavaScript
WebforSelf, 2018-05-15 23:49:02

How to add Yandex metrics goals to buttons created through the native WP constructor?

Friends, there is a Wordpress site with a native theme. Buttons are created through the constructor; there is no option to add an event simply to the html. Is there a js way to add an onclick event?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Klepko, 2018-05-16
@WebforSelf

$(".element_class").on('click', function(){
yaCounterXXXXXX.reachGoal('TARGET_NAME'); 
return true;
});

S
Shahin Agayev, 2020-07-21
@shahin1989

Yandex shortened its code a little: now it’s more relevant like this:

$(".element_class").on('click', function(){
ym(XXXXXXXX,'reachGoal','TARGET_NAME'); 
return true;
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question