In case you haven’t noticed, Google Tag Manager is getting an upgrade which will soon be automatically pushed by Google to all existing GTM V1 accounts starting June 1, 2015. Voluntary migration to this new version, V2, is also already in play. If you haven’t had a chance to familiarize yourself with the new version, then read more about it here.
Some of the changes include:
and there are many more!
This blog post is an update to our YouTube video tracking post, originally authored by Stéphane Hamel. We have highlighted the changes to Stéphane’s original GTM implementation to capture the changes needed to migrate your YouTube tracking from V1 to V2. The same prerequisites from the original V1 implementation apply to V2, and the only differences are in the configuration of the tags, triggers, and variables. We’ve also restructured the steps in Stephane’s original instructions to make it even more streamlined. So here we go!
This variable holds the value of the GA web property ID to which data will be sent.
This variable, when executed, checks the content of the page for any embedded YouTube. If found, “true” is returned, otherwise “false” is returned.
// Return "true" if there is at least one YouTube video on the page function () { for (var e = document.getElementsByTagName('iframe'), x = e.length; x--;) if (/youtube.com\/embed/.test(e[x].src)){ return true; } return false; }
Define a macro that will hold the value of the event category name pushed from the data layer.
Define a macro that will hold the value of the event action name pushed from the data layer.
Define a macro that will hold the value of the event label name pushed from the data layer.
Define a trigger that is executed when the dataLayer event name is “youtube”.
Define a trigger that is executed when the value returned from the variable “YouTube is present” is true, and when the event is “gtm.dom”.
This tag sends in the event data, that is pushed from the dataLayer, to the GA property.
This tag detects if there are any embedded YouTube videos on the page. If there are, then it listens for various actions coming from interactions with those videos, or when the video progresses.
Here is the code for you to copy/paste:
Don’t forget to thoroughly test your implementation in Preview mode before you go live with it.
Good luck with your YouTube video tracking! If you have any suggestions to improve this tracking, please don’t hesitate to let us know: nyuen@cardinalpath.com
Related Resources
New to Tag Management Systems (TMS)? This article explains Why Tag Management is the Way Forward in 2016, our State of Digital Marketing Analytics in the Top 500 Online Retailers report summarizes the adoption rate of TMS in eCommerce, and our expert panel had a lively discussion about the insights uncovered by the report.
As consumers become increasingly digitally savvy, and more and more brand touchpoints take place online,…
Marketers are on a constant journey to optimize the efficiency of paid search advertising. In…
Unassigned traffic in Google Analytics 4 (GA4) can be frustrating for data analysts to deal…
This website uses cookies.