Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Track YouTube Player Events in Google Analytics.




By default, the lunametrics-youtube.gtm.js script will be attached to all pages. To modify which pages the youtube-google-analytics script is attached to use hook_page_attachments() override with your custom logic.

The script will send tracking events when users Play, Pause, Watch to End, and watch 10%, 25%, 50%, 75%, and 90% of each video on the page. These defaults can be adjusted by modifying the object passed as the third argument at the bottom of the lunametrics-youtube.gtm.js script.


This module is nothing without the wonderful youtube-google-analytics script from LunaMetrics

Brought to you by your friends at Socha Dev.

Supporting organizations: 

Project information