This is a sandbox project, which contains experimental code for developer use only.
Track YouTube Player Events in Google Analytics.
- Download the
lunametrics-youtube.gtm.jsscript from https://github.com/lunametrics/youtube-google-analytics and install to
- Enable the module
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
This module is nothing without the wonderful
youtube-google-analytics script from LunaMetrics
Brought to you by your friends at Socha Dev.