L
L
lumb2018-11-18 22:44:52
HTML
lumb, 2018-11-18 22:44:52

How to correctly set a goal in Ya.Metrika on a video in html5?

I try like this, but there is no movement

<video playsinline="playsinline" controls poster="assets/mp4/firstkadr.jpg" onclick="yaCounter50927597.reachGoal('video'); return true;">
                <source src="assets/mp4/p720.mp4" type="video/mp4">
</video>

And is it right to use onclick in the same way as in browsers, on click, you can stop the video and maximize the window, and not just start it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lumb, 2018-11-19
@lumb

I did not find ready-made solutions on the Internet, keep

// Отслеживание завершения просмотра видео
var v = document.getElementsByTagName("video")[0];
v.addEventListener("ended",
function () {
  yaCounterXXXXXXXX.reachGoal('video'); return true;
  }
);

A
Alex, 2018-11-19
@pilolin

The video has its own list of events, I think you will find what you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question