Tracking Video in the Gutenberg WordPress editor with GA4
Google analytics 4 supposedly tracks videos straight out of the box. I don’t really use videos on my site, so have never really had the need to test this until I came across it on a client site.
So after digging around, you need to enable a parameter called enablejsapi. However, even when this was enabled, the only thing that was showing up in my GA4 was user_engagement.
After a lot of trial and error, I worked out I need to enable all the variables in Tag Manager. I have no idea why that would make a difference but it did.
In the Gutenberg editor is not as simple as just embedding the video. I just placed the Youtube embed iframe in a custom html block and add the parameter to the end.
The code for the video above is
You can now view these events in your GA4.
|Measurement option / event||Triggered…||Parameters|
|For embedded videos that have JS API support enabled, the following events are triggered:video_start when the video starts playingvideo_progress when the video progresses past 10%, 25%, 50%, and 75% duration timevideo_complete when the video ends||video_current_time, video_duration, video_percent, video_provider, video_title, video_url, visible (boolean)|
I would have thought this was something straightforward as its one of the enhanced measurement events Google was touting.