Media Analytics tracks youtube videos only with generic default title

Hello!

I searched the forum and googled a ton but couldn’t find a solution yet.

I have Media Analytics Plugin installed. It says, that it supports videoJS and that the tracking of Youtube Video title is done automatically.

When I load youtube videos with VideoJS and inspect the generated youtube iframe I can see it has a generic title="YouTube video player" attribute set. This title is then tracked by Matomo.

There is not point in tracking such a generic title. Do you know how to get the actual video title or at least how to overwrite this default one?

Thank you!

You can set the title using data-matomo-title attribute.
Please see Setting up: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

Hi Karthik!

Yes, the data-matomo-title attribute would be perfect. Unfortunately I didn’t find a way to add it to the generated iframe. Maybe it’s a videojs issue, but since I read Matomo supports videojs and this is such a common use case I thought there must already be a straight forward way to do this.

Source code:

<script>
jQuery(document).ready(function() {
    if (jQuery("#video_js_1073503_4768").length > 1) {
        videojs(document.getElementById("video_js_1073503_4768"), {
            "techOrder": ["youtube"],
            "sources": [{ 'type': 'video/youtube', 'youtube': { 'iv_load_policy': 1 }, 'src': 'https://www.youtube.com/watch?v=Eh44QPT1mPE' }],
            "controlBar": {}
        }).one(["waiting", "pause", "playing"], function() {
            var that = this;
            window.onbeforeunload = function(event) {
                that.currentTime(that.duration());
            };
        });
    }
});
</script>

<video id="video_js_1073503_4768" title="My Custom Matomo Youtube Title 123" data-matomo-title="My Custom Matomo Youtube Title 123" alt="My Custom Matomo Youtube Title 123" class="video-js vjs-default-skin vjs-big-play-centered vjs-16-9 akyt" controls preload="auto" width="640" height="264" poster='https://img.youtube.com/vi/Eh44QPT1mPE/0.jpg' data-setup='{ "techOrder": ["youtubeak"], "sources": [{ "type": "video/youtube", "src": "https://www.youtube.com/watch?v=Eh44QPT1mPE"}] }'>
</video>

After page load in DOM:

<div tabindex="-1" data-setup="{ &quot;techOrder&quot;: [&quot;youtube&quot;], &quot;sources&quot;: [{ &quot;type&quot;: &quot;video/youtube&quot;, &quot;src&quot;: &quot;https://www.youtube.com/watch?v=Eh44QPT1mPE&quot;}] }" poster="https://img.youtube.com/vi/Eh44QPT1mPE/0.jpg" preload="auto" class="video-js vjs-default-skin vjs-big-play-centered vjs-16-9 akyt vjs-paused video_js_1073503_4768-dimensions vjs-controls-enabled vjs-workinghover vjs-v6 vjs-youtube vjs-user-inactive" alt="My Custom Matomo Youtube Title 123" data-matomo-title="My Custom Matomo Youtube Title 123" title="My Custom Matomo Youtube Title 123" id="video_js_1073503_4768" lang="de" role="region" aria-label="Video Player">
  <div>
    <iframe id="video_js_1073503_4768_Youtube_api" style="width:100%;height:100%;top:0;left:0;position:absolute" class="vjs-tech" frameborder="0" allowfullscreen="1" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" title="YouTube video player" width="640" height="360" src="https://www.youtube.com/embed/Eh44QPT1mPE?controls=0&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;loop=0&amp;fs=0&amp;hl=de&amp;enablejsapi=1&amp;origin=https%3A%2F%2Fmywebsitedomain.com&amp;widgetid=1" enablejsapi="1"></iframe>
...

Matomo tracks “YouTube video player”.

Could you please contact our Support team at support@matomo.cloud and tag this conversation.