EDIT: the problem is no longer relevant.
GTM do not affect Youtube API anymore. (In the jsFiddle demo, video informations (state, currentTime, duration) are always correct).
Calling the Google Tag Manager seems to wreck the Youtube API.
Here is a fiddle demo :
Google Tag Manager & Youtube (jsfiddle)
// where thoses methods do not work anymore
player.getPlayerState();
player.getCurrentTime();
player.getDuration();
by commenting the line 16 Youtube API works again (correct state, correct currentTime / duration displayed).
Since the video is still playing, it seems like the js api is disabled.
Any idea to avoid that ?
The GTM container you load in the fiddle has a number of heavy customizations against the YouTube API in Custom JavaScript variables. By disabling / removing those variables, the YT methods on the page should work again.
So this would be a custom scripting issue in the Custom JavaScript variables you have created in GTM, and not a native issue with GTM's built-in functionalities.
Related
I recently tried to add an event listener to the Dailymotion player from the javascript API by following the documentation.
As I was not receiving any events, I discovered the list by doing dailymotion.events. This one returns me an object whose keys are in caps but not the values... the documentation shows us by an example that the events are in caps:
player.on("YOUR_EVENT", (state)).
Now that I’ve put the values in lowercase, I can hear the events of the Dailymotion player.
We’ve recently released a new library and the API naming construction did get updated.
If you are using the latest library: https://geo.dailymotion.com/libs/player.js, you can benefit from the new Player API and the list of events can be seen here: https://developers.dailymotion.com/player/#events
Please see example code: https://codepen.io/team/dailymotion-developer/pen/VwzpLXq
If you are using the legacy SDK, https://api.dmcdn.net/all.js please be aware we are in the process of discontinuing support for this product and advise you to adapt our newer technology.
However, in the meantime, the list of legacy events can be found here. https://developers.dailymotion.com/player/#player-api-events
As Google Tag Manager released the new update for built in variables for Youtube, I followed this tutorial of Simo Ahava for Youtube tracking: https://www.simoahava.com/analytics/the-youtube-video-trigger-in-google-tag-manager/
However, when I test my website in Preview mode, there is no gtm.video data layer. Because of that, there is no tag firing.
Any help will be appreciated, and if you believe my website has this video embedded code hidden, here is my page with video: https://www.magestore.com/magento-store-manager
Thank you!
Edited: Even if there is no gtm.video in Preview Mode, the tag actually still fires. You can check it in Real time mode of GA or wait until GA collects enough data.
We are having an issue with this functionality as well. We followed Simo's blog to implement and as of yesterday the functionality has become very unstable. We maybe have the tag firing 1 out of 20 page loads. We have tried loading the iframe_api as the first script. We have changed the ordering of the scripts. Something seems wrong with the code from Google.
I should also add that's it's not just the gtm.preview but if you publish the changes you will not see gtm.video firing with any regularity.
We think that GTM and YT API don't work well together - as per this post.
Google Tag Manager & Youtube Conflict
I'm writing a script that does stuff with the youtube advertisment videos that people have to watch before the actual videos. (These ad-vids at the start are just simple youtube videos from the brand's channel)
I've searched the whole source code and scripts, but I can't find the video id of those ads anywhere. It must be somewhere, but it seems to be hidden well.
Anybody got an idea where to look?
I did some research on your case.
The video id of the ad video is definitively not part of the initial source code, as you already figured out. Youtube makes an ajax-Request to the http://googleads.g.doubleclick.net/ API to get information about related ad videos.
If you take a look into the source code, you can see a lot of javascript that is related to the google ads part. By looking into the code, you can find URL routes to the API. See screenshot, it is just an excerpt:
But unfortunately you cannot simply copy the url and make a remote-call to it. By doing so, you get a 400 Bad Request response.
As i figured out, there are missing params, which are dynamically added by youtube's javascript.
If you compare the request, that is actually made by youtube, you can see that there are more params sent:
compared to the request, that is directly copied from source code:
The result of the working request looks like this:
I tried several ways to make the invalid API request work, but have not found a way. Debugging the javascript is not that easy, because its obfuscated and minified. But additionally the variables are scoped within the function. So anyways, you would not have access to them.
If you make a javascript breakpoint right before the XHR request, you can see the actual API request:
But it is within the Local scope, without access to it.
Later on, there is even a second request to the youtube data API to fetch information about the ad video
In my opinion, there are only two ways to get the video, both require javascript to run.
Look into the source code AFTER Javascript has run. Then you can get the id directly from your markup:
Hook onto the Ajax Requests and grab the data directly from your network traffic.
Is anybody else having issues with the YouTube APIs at the moment? About 2.5hrs ago I had reports from two different clients that their playback on sites had stopped working. They all appear to be functioning correctly on the website side of things but the returned YT.player object has no playVideo() method and never fires onReady. No code has changed on either of these things for months.
A URL you can view the problem on is here (though the scripts are minified) - http://brisbanepowerhouse.org/videos/the-removalists-david-williamson-interview/
You could also try the first video on this page (unminified) - http://thenewdaily.com.au/videos/?author_name=susannah-guthrie - but it is pretty regularly updated with content and there is no guarantee that it will still be a YouTube video at #1 by the time someone looks (the site also uses Vimeo embeds)
cheers!
I test with browser with the link I get from "http://www.youtube.com/get_video_info?&video_id=xx" to see if it is be able to download.
After remove some parameters from original link, some works but some still don't.
I read some post here but most of are pretty old. A lot of change since then.
I wonder if there are somebody working on this recently.
The purpose I need this is because my youtube view program need a better quality video to display.
This is link doesn't work:
http://r17---sn-tt17rn7e.c.youtube.com/videoplayback?fexp=902529%2C932000%2C906383%2C902000%2C919512%2C929903%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C919373%2C930803%2C906836%2C920201%2C929602%2C930101%2C930603%2C900824%2C910223&ipbits=8&expire=1364854787&sver=3&mt=1364829200&newshard=yes&id=26c94a41dba396f5&key=yt1&upn=GrcnDUPfreQ&cp=U0hVSVhQUl9NUUNONV9QSlZIOm9BbnVkMTJzOXE5&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&ip=173.248.214.165&itag=34&ms=au&source=youtube&mv=m&signature=9593596F58B377FAA4C8F5A4516C7F53CE473340.507CA2EA250CEED2E2B2377FD70EE1A0478EE322&type=video/mp4; codecs="avc1.42001E, mp4a.40.2"&itag=18&
What wrong with it? I removed fallback_path and replace sig with signature.
The working link is for webm. This is for h264. Both have the same kind of parameters.
And this is working now.
http://r17---sn-tt17rn7e.c.youtube.com/videoplayback?fexp=909708%2C912514%2C930802%2C932400%2C916624%2C931009%2C932000%2C906383%2C902000%2C919512%2C929903%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C930807%2C919373%2C906836%2C920201%2C929602%2C930101%2C930603%2C900824%2C910223&ms=au&itag=44&mt=1364825784&ipbits=8&cp=U0hVSVhQT19NUUNONV9QSlNCOlp5ZGoyMXJ3emlq&ip=173.248.214.165&upn=ohH0s8EjPyo&newshard=yes&source=youtube&ratebypass=yes&mv=m&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&id=26c94a41dba396f5&expire=1364851187&key=yt1&sver=3&signature=798EED35782B846D2B0EA190A17E837A0DBA18EA.AD56BCF6365AAD974C18F09F352F9422084C50AC&type=video/webm; codecs="vp8.0, vorbis"&quality=large,itag=35&
That's not a supported method of interacting with YouTube. You need to use one of the official YouTube Player mechanisms to display YouTube videos.
Please familiarize yourself with the YouTube API Terms of Service if you have any more questions.