YouTube Tracking and Google Analytics Integration

Roshanchauhan
Frequent Visitor
Roshanchauhan

Hi There,

I have set the YouTube tracking as mentioned in the following URL https://community.tealiumiq.com/t5/iQ-Tag-Management/YouTube-Video-Tracking-Setup-Guide-for-Tealium-... . But I am not able to pass the YouTube values to the Google Analytics, can anyone help me in this how to setup for the Google Analytics.

Few more queries:

1. Is it mandatory to add the following script on the webpage? 

<script type="text/javascript">
var utag_data = {
  video_id : "", // Contains the video ID.
  video_name : "", // Contains the name of the video.
  video_duration : "", // Contains the duration of the video. This value should be in seconds.
  video_offset : "", // Contains the time into a video at which a certain state occurs.
  video_state : "", // Contains the state of the video, e.g. start, play, pause, milestone, end.
  video_player : "", // Contains the name of the video player.
  video_player_version : "", // Contains the version of the video player.
  event_category : "", // GA: event_category
  event_action : "", // GA: event_action
  event_label : "", // GA: event_label
  event_value : "", // GA: event_value
  event_name : "", // Tealium variable to identify unique events eg. social_share, user_login, etc.
  tealium_event : "", // Identifies the unique names of tracked events.
  page_type : "" // Tealium variable to identify page types/templates eg. home, category, search, product, etc.
}
</script>

 

As for now, I have added only one following script on the website. Please suggest I need to make changes in this or is it ok.

<!-- Loading script asynchronously -->
<script type="text/javascript">
    (function(a,b,c,d){
    a='//tags.tiqcdn.com/utag//main/prod/utag.js';
    b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
    a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a);
    })();
</script>

 

Thanks!

6 REPLIES 6

YouTube Tracking and Google Analytics Integration

abrahameaso
Contributor
abrahameaso Contributor

 

Hi @Roshanchauhan,

It is not mandatory to add all variables within utag_data data layer definition along with Tealium container tag(code snippet). You may get these variables as part of the standard Tealium container tag downloaded from the Code center within Tealium IQ. Those are a standardized template that Tealium creates for our ease to understand the applicable list of variables. You may only need to define and set values for applicable variables for the current page view or other actions taken.

Yes second part in your post is the Tealium Container tag. This is mandatory for the tealium code to work. 

Related to Youtube video tracking, looks like you already followed the link with instructions available within Tealium Learning Community. I think the code and instructions provided in the link covers the creation of Tealium Extension to track the videos. There is a second part to this, where we need to have a Tag created to send these data to analytics or other systems that collects the data. This may change based on which tag used to send data. 

In our case a Google Analytics tag should be created to trigger video event tracking calls and also map the video specific variables like video title, name, duration etc within the tag to send that data in the tracking call. 

 For our easy reference, please find below a sample screenshot of a GA tag created with variables being mapped within Tealium IQ. These mappings are just created as a sample, feel free to customize it based on your needs.

Tips: GA event tracking requires following data layer mappings within the tag. eventAction & eventCategory. Screenshot given are just for example purpose. 

 Hope this helps.

Google Analytics Tag Mapping for Youtube Tracking.png

YouTube Tracking and Google Analytics Integration

Roshanchauhan
Frequent Visitor
Roshanchauhan
Thank You Abrahameaso for your assistance.

If I add following script without variables or will not add the following part of the script on the website then my all tags will work?

&lt;script type="text/javascript">
var utag_data = {

}
&lt;/script&gt;

YouTube Tracking and Google Analytics Integration

Roshanchauhan
Frequent Visitor
Roshanchauhan

@abrahameaso I have implemented the same but I am not able to track the videos here is the screenshot. 

a.png

YouTube Tracking and Google Analytics Integration

abrahameaso
Contributor
abrahameaso Contributor

@Roshanchauhan

Just wondering why you are using "Google Analytics(gtag.js)" tag. Per my knowledge, for google analytics tracking, we should be using "Google Analytics(analytics.js)" or "Google Analytics(ga.js)".

In my testing, i was using "Google Analytics(analytics.js)".

Additionally you may want to check if the youtube video iframe has enablejsapi=1 attribute defined for the Youtube API to work. 

Special instructions: Usage of ‘origin’ parameter in the ‘iframe’ ‘src’ field of a YouTube video prevents analytics tracking, if the domain of the ‘origin’ parameter is different from the page domain where the video is shown. In order to enable analytics tracking, the ‘origin’ parameter has to be set to the same domain where the video is shown. Removing the origin parameter will also enable analytics tracking.

If still not working, try enable web browser debugging within Youtube Tealium extension code and see if the youtube events are captured correctly and utag.link() calls are triggered correctly. In some cases, errors or exceptions may prevent the video event binding and that might be the reason tracking is not working. 

Thanks

Abraham

YouTube Tracking and Google Analytics Integration

Roshanchauhan
Frequent Visitor
Roshanchauhan

@abrahameaso Thank you so much problem is solved.

The problem was "Google Analytics(gtag.js)" now I used "Google Analytics(ga.js)" this works for me.

So this means Tealium not support gtag.js yet If I am not wrong.

 

 

YouTube Tracking and Google Analytics Integration

abrahameaso
Contributor
abrahameaso Contributor

Sounds Perfect!!. More than happy that feedbacks helped.

I haven’t worked on gtag earlier. But it was very interesting to do some hands-on with this new tag.  Per my understanding this tag is on its way getting matured. I do notice that utag.view calls are working for this tag. But utag.link calls are not triggering the google analytics events calls. Probably there would be more updates and documentation coming our way from the Tealium side to get a better understanding on tracking gtag Google Analytics.

Thanks

Abraham