This tag sends in the event data, that is pushed from the dataLayer, to the GA property.

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:

  1. “rules” are now renamed to “triggers”
  2. “macros” are now renamed to “variables”
  3. auto-event listeners are no longer needed, and firing a tag based on a click is done by creating a trigger type of “Click”
  4. built-in variables will replace the standard, built-in macros (eg. {{url}}, {{element id}}, {{event}}, etc.)

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!


Create Your Variables

Web Property ID

This variable holds the value of the GA web property ID to which data will be sent.

  • Variable name:
    • WebProperty ID
  • Variable type:
    • Constant
  • Variable configuration:
    • Value = UA-XXXXXX-Y (use your own web property ID)

Variable Configuration in GTM

Is YouTube Present?

This variable, when executed, checks the content of the page for any embedded YouTube. If found, “true” is returned, otherwise “false” is returned.

  • Variable name:
    • YouTube is present
  • Variable type:
    • Custom JavaScript
  • Variable configuration:
// 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;
}Checks the content of the page for any embedded YouTube.

Data Layer Category

Define a macro that will hold the value of the event category name pushed from the data layer.

  • Variable name:
    • dataLayer category
  • Variable type:
    • Data Layer Variable
  • Variable configuration:
    • Data Layer Variable Name: eventCategory
    • Data Layer Version: Version 2

Defines a macro that will hold the value of the event category name pushed from the data layer.

Data Layer Action

Define a macro that will hold the value of the event action name pushed from the data layer.

  • Variable name:
    • dataLayer action
  • Variable type:
    • Data Layer Variable
  • Variable configuration:
    • Data Layer Variable Name: eventAction
    • Data Layer Version: Version 2

Defines a macro that will hold the value of the event action name pushed from the data layer.

Data Layer Label

Define a macro that will hold the value of the event label name pushed from the data layer.

  • Variable name:
    • dataLayer label
  • Variable type:
    • Data Layer Variable
  • Variable configuration:
    • Data Layer Variable Name: eventLabel
    • Data Layer Version: Version 2

Defines a macro that will hold the value of the event label name pushed from the data layer.

Create Your Triggers

YouTube Event Trigger

Define a trigger that is executed when the dataLayer event name is “youtube”.

  • Trigger name:
    • YouTube event
  • Trigger event type:
    • Custom Event
  • Trigger fires on:
    • Event name: youtube

Defines a trigger that is executed when the dataLayer event name is "youtube"

YouTube Present Trigger

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”.

  • Trigger name:
    • YouTube present
  • Trigger event type:
    • Custom Event
  • Trigger fires on:
    • Event name: gtm.dom
    • “YouTube is present” equals true

Defines a trigger that is executed when the value returned from the variable "YouTube is present" is true, and when the event is "gtm.dom"

Create Your Tags

YouTube Event Tag

This tag sends in the event data, that is pushed from the dataLayer, to the GA property.

  • Tag name:
    • YouTube Event
  • Tag product:
    • Google Analytics
  • Tag type:
    • Universal Analytics
  • Tag configuration:
    • Tag type: Universal Analytics
    • Tracking ID: {{WebProperty ID}}
    • Track Type: Event
    • Category: {{dataLayer category}}
    • Action: {{dataLayer action}}
    • Label: {{dataLayer label}}
    • Fields to Set: Field Name = “useBeacon”, Field Value = “true”
  • Tag firing rule:
    • Tag triggered by “YouTube event” trigger

This tag sends in the event data, that is pushed from the dataLayer, to the GA property.

YouTube Listener Tag

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.

  • Tag name:
    • YouTube Listener
  • Tag product:
    • Custom HTML Tag
  • Tag configuration:
    • Tag type: Custom HTML
    • HTML: (click here for a copy of the YouTube listener code)
  • Tag firing rule:
    • Tag triggered by “YouTube present” trigger

YouTube Listener

 

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.

Message Sent

Thank you for registering.

Cardinal Path hosted a live session to connect with you and answer all your questions on Google Analytics.
Get all the expertise and none of the consultancy fees in this not-to-be-missed, rapid-fire virtual event.

Thank you for submitting the form.

Thank you for submitting the form.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you.

Click here to download access the tool.

Message Sent

Thank you for registering.

Message Sent

Thank you.

Message Sent

Thank you.

Message Sent

Thank you

Message Sent

Thank you

Message Sent

Thank you.

Message Sent

Thank you

Message Sent

Thank you.

Message Sent

Success!
Your message was received.

Thank you.

Thank you for registering.

Cardinal Path is continuing with its series of free training. Next we are conducting training on Google Data Studio. Check it out here.

Message Sent

Thank you for registering.

Thank you for your submission.

Your request has been submitted and a rep will reach out to you shortly.

Message Sent

Thank you for your interest.

Thank you for registering.

You should receive a confirmation email from GoToWebinar with your unique webinar login information. If you do not receive this email or have trouble logging in to the event, please email asmaa.mourad@cardinalpath.com.

Thank you for subscribing!

You're now looped into the world's largest GMP resource hub!

Thank you for your submission.

Thank you for your submission.

Thank you for your submission.

Thank you for your submission.

Message Sent

Thank you for registering.

Message Sent

Thank you for your submission.

Thank you for your submission.

Message Sent

Thank you for registering.

Thank you for registering.​

Paid media spend by Government websites increased a whopping 139% YoY in 2020.

2020 Online Behavior Live Dashboard

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

2020 Online Behavior Live Dashboard

Thank you for your submission.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Success! Thank you
for reaching out.