hello
i need to track video playing for one video (no need media plugin just for one)
i do this
My html
<div id="motion" class="et_pb_module et_pb_video et_pb_video_0 lwp-no-download">
<div class="et_pb_video_box">
<video controls="" controlslist="nodownload">
<source type="video/mp4" src="mavideo.mp4">
<source type="video/webm" src="mavideo.webm">
</video></div>
<div style="" class="et_pb_video_overlay"><div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div></div>
</div>
1 j create a tag
2 i add action on click
<script>_paq(['trackEvent','play video', 'properly sent', 'it works']);</script>
but nothing in event (no categorie, no return)
thanks for any help
melbao
January 25, 2023, 7:34pm
2
Hello yannick berges,
you will track wich video-file is played? Use currentSrc
with an onplay
event.
onplay="_paq.push(['trackEvent','video', 'video-play', this.currentSrc]);"
<div id="motion" class="et_pb_module et_pb_video et_pb_video_0 lwp-no-download">
<div class="et_pb_video_box">
<video controls="" controlslist="nodownload" onplay="_paq.push(['trackEvent','video', 'video-play', this.currentSrc]);">
<source type="video/mp4" src="mavideo.mp4">
<source type="video/webm" src="mavideo.webm">
</video></div>
<div style="" class="et_pb_video_overlay"><div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div></div>
</div>
Consider, the matomo Event Tracking has 3 values with 2 hierachies.
_paq.push(['trackEvent','Categories', 'Actions', 'Names']);
Categories
– Actions
Actions
– Names
but not
Categories
– Actions
— Names
Edit: Track only the filename without extension:
this.currentSrc.replace(string.split('.').pop(), "")
hello
i add this in head
<script>
window.onload = function() {
document.getElementById('motion').querySelector('video').addEventListener('play', function(e) {
_paq.push(['trackEvent', 'Categories', 'play video', 'motion']);
console.log('video jouée');
});
}</script>
when i test clic on video console.log is ok but i didn’t find any return to matomo
no category in event, etc …
i do a mistake for sure but i doesn’t understand where
thanks for your help
melbao
January 26, 2023, 10:14pm
5
Thanks Philippe,
@yannick_berges , i have no idea. Try this:
var documentreadystateinterval = setInterval(function() {
if (document.readyState === "complete") {
var videoelements = document.getElementsByTagName("video");
for (var i = 0; i < videoelements.length; i++) {
videoelements[i].addEventListener('play', function(e) {
_paq.push(['trackEvent', 'Categories', 'play video', 'motion']);
console.log('video jouée');
});
}
clearInterval(documentreadystateinterval);
}
}, 100);
Otherwise maybe your tracking has a failure.
AHH my code works just need time to see return in matomo
thanks for all help !
Hi @yannick_berges
Yes indeed, you need to wait data are archived:
To be sure tracking works well (in case you don’t have the the QueueTracking plugin activated that could delay a few), use the Real-time report: