D
D
Denis Goncharenko2016-08-15 19:30:30
JavaScript
Denis Goncharenko, 2016-08-15 19:30:30

Why does the goal in Yandex Metrica not work?

I created javascript goals, hung a couple of goals on links, they work, created another goal for submitting the form, I don’t need clicks on the submit button, namely submitting the form, the form is sent to ajax, so onsubmit will not work either. I call the code directly from the function that fires on completion of the ajax request:

success: function(data) {
    yaCounter39003210.reachGoal('SEND_FORM');
    modal.close();
    success.open();
},

But nothing appears in Metrica, what's the problem?
Here's what's in the logs, it says that both goals work, both opening the form and sending it:
PZIv9kqwiIFPJ044pJhEFrxlUw_dc0z7D94ggoi
But in the metrics admin panel, the first goal has been updated, and the second one does not appear:
PZIv9kqwiIFPJ044pJhEFmX6VpejlYIquAeaHQcV

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Goncharenko, 2016-08-15
@denis79513

I'll answer myself, I found a solution, it's right to do like this:

yaCounter39003210.reachGoal('SEND_FORM', function () {
    modal.close();
    success.open();
});

K
kn1ght_t, 2016-08-15
@kn1ght_t

in appearance, everything is done correctly (of course, if the counter number is correct and the target is correct)
the metric does not instantly display the triggering of the target, maybe the point is that
in general, insert some console log after the target is triggered to check that this part of the code executed
+ I would probably insert this thing at the end of success, suddenly the metric will disappear, then the modal windows will not close / open after sending

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question