How do I prevent YouTube from placing cookies when tracking YouTube videos?
Matomo supports the tracking of YouTube videos via our Media Analytics feature. To track these videos, Media Analytics uses the YouTube iFrame API. This YouTube iFrame API places cookies in your browser for the domain .youtube.com
and it happens even if cookies are disabled in the Matomo JavaScript tracker.
The YouTube iFrame API currently sets two cookies named VISITOR_INFO1_LIVE
and YSC
. This is also the case if you load the videos using the youtube-nocookie.com
domain. To understand more about the cookies placed by YouTube, read this article.
There may be cases where you do not want YouTube to set such cookies. The only way to achieve this is by not tracking any of your YouTube videos using Media Analytics. You can disable the tracking of YouTube videos by adding the below JavaScript tracking code to your website.
window._paq = window._paq || [];
window.paq.push(['MediaAnalytics::removePlayer', 'youtube']);