Track event iframe youtube

Hi everyone, hope you guys doing well.

I know matomo have media analytic plugins to track detail record from the youtube. However, I only need simple way to trigger event if someone click play the button, is there any simple way to capture youtube on iframe?
I see one of post that do exactly what i want, the question is I don’t know how to put it on matomo tag manager,

is it on the trigger section or tag custom html section?
I tried put it on tag custom html section but I don’t know what is the trigger should I use?
any reference or how to solve this simple thing will be appreciated, thank you.

For general security reasons, there is no access to the content of iframes. Tracking of media content only works with self-hosted videos and audios.

1 Like

Certainly! For your specific requirement, place the YouTube tracking script in the “Tag Custom HTML” section in Matomo Tag Manager. Since you want to trigger an event when someone clicks the play button, you can set up a trigger related to the “play” action. Ensure the trigger is configured to fire when the play button is clicked. This setup will capture YouTube interactions effectively.

Hi thank you for your reply,
I noticed to put the tracking script at “Tag Custom HTML”.
but I still don’t know how to put trigger, for example I put iframe id as “youtube-id”, but it won’t trigger from the matomo, I notice that iframe only triggered by the frame (not the content), is there any other way or i just put it on the wrong way?

thank you

Ah, OK, there is a Matomo Plugin named Media Analytics.

To use this Matomo Media Analytics Plugin for YouTube videos, you must use this YouTube Iframe-API:

But more knowledge is not on my side. Maybe put also your matomo tracking in this Iframe.

Or … have you read this?

Tracking YouTube videos

adding a URL parameter ?enablejsapi=1 to all your video source URLs

Check your browser console for the requests (firering) and errors.

1 Like